diff options
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Services/DHCPClient/DHCPv4Client.cpp | 11 | ||||
-rw-r--r-- | Userland/Services/DHCPClient/DHCPv4Client.h | 4 |
2 files changed, 6 insertions, 9 deletions
diff --git a/Userland/Services/DHCPClient/DHCPv4Client.cpp b/Userland/Services/DHCPClient/DHCPv4Client.cpp index 421cf9e4d8..7b9d5f2728 100644 --- a/Userland/Services/DHCPClient/DHCPv4Client.cpp +++ b/Userland/Services/DHCPClient/DHCPv4Client.cpp @@ -10,6 +10,7 @@ #include <AK/JsonObject.h> #include <AK/JsonParser.h> #include <AK/Random.h> +#include <AK/Try.h> #include <LibCore/File.h> #include <LibCore/Timer.h> #include <stdio.h> @@ -161,20 +162,16 @@ void DHCPv4Client::try_discover_ifs() } } -Result<DHCPv4Client::Interfaces, String> DHCPv4Client::get_discoverable_interfaces() +ErrorOr<DHCPv4Client::Interfaces> DHCPv4Client::get_discoverable_interfaces() { - auto file = Core::File::construct("/proc/net/adapters"); - if (!file->open(Core::OpenMode::ReadOnly)) { - dbgln("Error: Failed to open /proc/net/adapters: {}", file->error_string()); - return String { file->error_string() }; - } + auto file = TRY(Core::File::open("/proc/net/adapters", Core::OpenMode::ReadOnly)); auto file_contents = file->read_all(); auto json = JsonValue::from_string(file_contents); if (!json.has_value() || !json.value().is_array()) { dbgln("Error: No network adapters available"); - return String { "No network adapters available" }; + return Error::from_string_literal("No network adapters available"sv); } Vector<InterfaceDescriptor> ifnames_to_immediately_discover, ifnames_to_attempt_later; diff --git a/Userland/Services/DHCPClient/DHCPv4Client.h b/Userland/Services/DHCPClient/DHCPv4Client.h index cdd5cf7b00..0664b94837 100644 --- a/Userland/Services/DHCPClient/DHCPv4Client.h +++ b/Userland/Services/DHCPClient/DHCPv4Client.h @@ -7,9 +7,9 @@ #pragma once #include "DHCPv4.h" +#include <AK/Error.h> #include <AK/HashMap.h> #include <AK/OwnPtr.h> -#include <AK/Result.h> #include <AK/String.h> #include <AK/Vector.h> #include <LibCore/UDPServer.h> @@ -53,7 +53,7 @@ public: Vector<InterfaceDescriptor> ready; Vector<InterfaceDescriptor> not_ready; }; - static Result<Interfaces, String> get_discoverable_interfaces(); + static ErrorOr<Interfaces> get_discoverable_interfaces(); private: explicit DHCPv4Client(); |