diff options
author | FearlessTobi <thm.frey@gmail.com> | 2019-11-03 08:07:04 +0100 |
---|---|---|
committer | FearlessTobi <thm.frey@gmail.com> | 2020-01-23 20:55:26 +0100 |
commit | bbd85a495a3576a5ec99cd69b54e983653b38ea4 (patch) | |
tree | a9dbc8ebf61179a1ed27f004ab56e767b75bd315 /src/input_common/udp/protocol.cpp | |
parent | 0fe11746fcb37de2465cdbbe74be6ad4a59228e5 (diff) |
Address second part of review comments
Diffstat (limited to 'src/input_common/udp/protocol.cpp')
-rw-r--r-- | src/input_common/udp/protocol.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/input_common/udp/protocol.cpp b/src/input_common/udp/protocol.cpp index 16da706d5b..a982ac49de 100644 --- a/src/input_common/udp/protocol.cpp +++ b/src/input_common/udp/protocol.cpp @@ -32,21 +32,21 @@ namespace Response { std::optional<Type> 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<Type> 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<Type> 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; } |