--- nono/vm/ethernet.cpp 2026/04/29 17:05:38 1.1.1.10 +++ nono/vm/ethernet.cpp 2026/04/29 17:05:43 1.1.1.11 @@ -34,7 +34,13 @@ EthernetDevice::Create() { // ホストドライバを作成してこのデバイスと紐付ける int n = GetId() - OBJ_ETHERNET0; - hostnet.reset(new HostNetDevice(this, n)); + try { + hostnet.reset(new HostNetDevice(this, n)); + } catch (...) { } + if ((bool)hostnet == false) { + warnx("Failed to initialize HostNetDevice(%u) at %s", n, __method__); + return false; + } hostnet->SetRxCallback(ToDeviceCallback(&EthernetDevice::HostRxCallback)); @@ -129,11 +135,10 @@ EthernetDevice::CRC32(const uint8 *buf, static const uint32 CRC_POLY = 0x04c11db6; uint32 crc; uint32 cy; - uint32 s; crc = 0xffffffff; for (size_t i = 0; i < buflen; i++) { - s = buf[i]; + uint32 s = buf[i]; for (size_t j = 0; j < 8; j++) { cy = ((crc & 0x80000000U) ? 0x01 : 0x00) ^ (s & 0x01); crc <<= 1; @@ -154,12 +159,11 @@ EthernetDevice::CRC32(const MacAddr& mac { static const uint32 CRC_POLY = 0x04c11db6; uint32 crc; - uint32 cy; uint64 s = mac.Get(); crc = 0xffffffff; for (size_t i = 0; i < mac.size() * 8; i++) { - cy = ((crc & 0x80000000U) ? 0x01 : 0x00) ^ (s & 0x01); + uint32 cy = ((crc & 0x80000000U) ? 0x01 : 0x00) ^ (s & 0x01); crc <<= 1; s >>= 1; if (cy) {