Remove Xml_node::attribute accessors

This patch removes the two 'Xml_node::attribute' accessors along with
the 'Nonexistent_attribute' exception.

Issue #5245
Fixes #5246
This commit is contained in:
Norman Feske
2024-06-11 14:03:50 +02:00
parent 84bbde2879
commit 7de2f57ef2
27 changed files with 178 additions and 268 deletions

View File

@ -90,15 +90,12 @@ struct Main
usb_config = config_rom.xml().attribute_value("configuration", 0ul);
/* retrieve possible MAC */
try {
Nic::Mac_address mac;
Xml_node::Attribute mac_node = config_rom.xml().attribute("mac");
mac_node.value(mac);
use_mac_address = config_rom.xml().has_attribute("mac");
if (use_mac_address) {
auto const mac = config_rom.xml().attribute_value("mac", Nic::Mac_address{});
mac.copy(mac_address);
use_mac_address = true;
log("Trying to use configured mac: ", mac);
} catch (...) {
use_mac_address = false;
}
}
};

View File

@ -1619,34 +1619,31 @@ class Vfs::Lxip_file_system : public Vfs::File_system,
return;
}
try {
Addr ip_addr = config.attribute_value("ip_addr", Addr());
Addr netmask = config.attribute_value("netmask", Addr());
Addr gateway = config.attribute_value("gateway", Addr());
Addr nameserver = config.attribute_value("nameserver", Addr());
Addr ip_addr = config.attribute_value("ip_addr", Addr());
Addr netmask = config.attribute_value("netmask", Addr());
Addr gateway = config.attribute_value("gateway", Addr());
Addr nameserver = config.attribute_value("nameserver", Addr());
if (ip_addr == "") {
warning("Missing \"ip_addr\" attribute. Ignoring network interface config.");
return;
} else if (netmask == "") {
warning("Missing \"netmask\" attribute. Ignoring network interface config.");
return;
}
if (ip_addr == "") {
warning("Missing \"ip_addr\" attribute. Ignoring network interface config.");
throw Genode::Xml_node::Nonexistent_attribute();
} else if (netmask == "") {
warning("Missing \"netmask\" attribute. Ignoring network interface config.");
throw Genode::Xml_node::Nonexistent_attribute();
}
log("static network interface: ip_addr=",ip_addr," netmask=",netmask);
log("static network interface: ip_addr=",ip_addr," netmask=",netmask);
genode_socket_config address_config = {
.dhcp = false,
.ip_addr = ip_addr.string(),
.netmask = netmask.string(),
.gateway = gateway.string(),
.nameserver = nameserver.string(),
};
genode_socket_config address_config = {
.dhcp = false,
.ip_addr = ip_addr.string(),
.netmask = netmask.string(),
.gateway = gateway.string(),
.nameserver = nameserver.string(),
};
genode_socket_config_address(&address_config);
} catch (...) { }
}
genode_socket_config_address(&address_config);
}
/*************************