From bbd85a495a3576a5ec99cd69b54e983653b38ea4 Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Sun, 3 Nov 2019 08:07:04 +0100 Subject: Address second part of review comments --- src/input_common/udp/protocol.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/input_common/udp/protocol.cpp') diff --git a/src/input_common/udp/protocol.cpp b/src/input_common/udp/protocol.cpp index 16da706d5..a982ac49d 100644 --- a/src/input_common/udp/protocol.cpp +++ b/src/input_common/udp/protocol.cpp @@ -32,21 +32,21 @@ namespace Response { std::optional Validate(u8* data, std::size_t size) { if (size < sizeof(Header)) { LOG_DEBUG(Input, "Invalid UDP packet received"); - return {}; + return std::nullopt; } Header header{}; std::memcpy(&header, data, sizeof(Header)); if (header.magic != SERVER_MAGIC) { LOG_ERROR(Input, "UDP Packet has an unexpected magic value"); - return {}; + return std::nullopt; } if (header.protocol_version != PROTOCOL_VERSION) { LOG_ERROR(Input, "UDP Packet protocol mismatch"); - return {}; + return std::nullopt; } if (header.type < Type::Version || header.type > Type::PadData) { LOG_ERROR(Input, "UDP Packet is an unknown type"); - return {}; + return std::nullopt; } // Packet size must equal sizeof(Header) + sizeof(Data) @@ -59,7 +59,7 @@ std::optional Validate(u8* data, std::size_t size) { Input, "UDP Packet payload length doesn't match. Received: {} PayloadLength: {} Expected: {}", size, header.payload_length, data_len + sizeof(Type)); - return {}; + return std::nullopt; } const u32 crc32 = header.crc; @@ -70,7 +70,7 @@ std::optional Validate(u8* data, std::size_t size) { result.process_bytes(data, data_len + sizeof(Header)); if (crc32 != result.checksum()) { LOG_ERROR(Input, "UDP Packet CRC check failed. Offset: {}", offsetof(Header, crc)); - return {}; + return std::nullopt; } return header.type; } -- cgit v1.2.3