summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-07-11 18:00:31 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-11 18:00:31 +0200
commit241bbce264f5e3593b7ec904fed419456c39fe3e (patch)
treedb54a2d7dd46b783f04e061d93315df85fd03828
parente4dfb0fdf385ea830c729558f4c58091e5a16dcc (diff)
downloadserenity-241bbce264f5e3593b7ec904fed419456c39fe3e.zip
Kernel: LoopbackAdapter::create() => try_create()
Allow this to fail (although we VERIFY that it succeeds during boot for now, since we don't want to boot without a loopback adapter.)
-rw-r--r--Kernel/Net/LoopbackAdapter.cpp4
-rw-r--r--Kernel/Net/LoopbackAdapter.h2
-rw-r--r--Kernel/Net/NetworkingManagement.cpp5
3 files changed, 6 insertions, 5 deletions
diff --git a/Kernel/Net/LoopbackAdapter.cpp b/Kernel/Net/LoopbackAdapter.cpp
index 647c168550..28f5a2e7f4 100644
--- a/Kernel/Net/LoopbackAdapter.cpp
+++ b/Kernel/Net/LoopbackAdapter.cpp
@@ -11,9 +11,9 @@ namespace Kernel {
static bool s_loopback_initialized = false;
-NonnullRefPtr<LoopbackAdapter> LoopbackAdapter::create()
+RefPtr<LoopbackAdapter> LoopbackAdapter::try_create()
{
- return adopt_ref(*new LoopbackAdapter());
+ return adopt_ref_if_nonnull(new LoopbackAdapter());
}
LoopbackAdapter::LoopbackAdapter()
diff --git a/Kernel/Net/LoopbackAdapter.h b/Kernel/Net/LoopbackAdapter.h
index d02fe147be..046350772a 100644
--- a/Kernel/Net/LoopbackAdapter.h
+++ b/Kernel/Net/LoopbackAdapter.h
@@ -17,7 +17,7 @@ private:
LoopbackAdapter();
public:
- static NonnullRefPtr<LoopbackAdapter> create();
+ static RefPtr<LoopbackAdapter> try_create();
virtual ~LoopbackAdapter() override;
virtual void send_raw(ReadonlyBytes) override;
diff --git a/Kernel/Net/NetworkingManagement.cpp b/Kernel/Net/NetworkingManagement.cpp
index 8db21be7af..2b0719c072 100644
--- a/Kernel/Net/NetworkingManagement.cpp
+++ b/Kernel/Net/NetworkingManagement.cpp
@@ -101,8 +101,9 @@ bool NetworkingManagement::initialize()
m_adapters.append(adapter.release_nonnull());
});
}
- auto loopback = LoopbackAdapter::create();
- m_adapters.append(loopback);
+ auto loopback = LoopbackAdapter::try_create();
+ VERIFY(loopback);
+ m_adapters.append(*loopback);
m_loopback_adapter = loopback;
return true;
}