1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

NetworkTask: Don't crash on startup if there's no E1000 NIC present.

This commit is contained in:
Andreas Kling 2019-05-18 00:22:08 +02:00
parent 33d0916d29
commit 8f3022b5c1

View file

@ -54,10 +54,12 @@ void NetworkTask_main()
{ {
LoopbackAdapter::the(); LoopbackAdapter::the();
auto* adapter_ptr = E1000NetworkAdapter::the(); auto* adapter = E1000NetworkAdapter::the();
ASSERT(adapter_ptr); if (!adapter)
auto& adapter = *adapter_ptr; dbgprintf("E1000 network card not found!\n");
adapter.set_ipv4_address(IPv4Address(192, 168, 5, 2));
if (adapter)
adapter->set_ipv4_address(IPv4Address(192, 168, 5, 2));
auto dequeue_packet = [&] () -> ByteBuffer { auto dequeue_packet = [&] () -> ByteBuffer {
auto packet = LoopbackAdapter::the().dequeue_packet(); auto packet = LoopbackAdapter::the().dequeue_packet();
@ -65,8 +67,8 @@ void NetworkTask_main()
dbgprintf("Receive loopback packet (%d bytes)\n", packet.size()); dbgprintf("Receive loopback packet (%d bytes)\n", packet.size());
return packet; return packet;
} }
if (adapter.has_queued_packets()) if (adapter && adapter->has_queued_packets())
return adapter.dequeue_packet(); return adapter->dequeue_packet();
return { }; return { };
}; };