mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
DHCPClient: Replace Result<T, E> use with ErrorOr<T>
This commit is contained in:
parent
d1477bcb8e
commit
fbbb87d517
Notes:
sideshowbarker
2024-07-18 01:23:32 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/fbbb87d5175
2 changed files with 6 additions and 9 deletions
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue