Decoder: 64-bit shift to avoid UB

Shifting a value by more than the size of its type is UB.

This was actually causing mangled serial numbers with
optimization on using Clang 12 on Linux.
This commit is contained in:
Paul Hollinsky
2021-01-29 17:32:07 -05:00
parent 09a02ff420
commit 4d655da69d
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ namespace icsneo {
class Decoder {
public:
static uint64_t GetUInt64FromLEBytes(uint8_t* bytes);
static uint64_t GetUInt64FromLEBytes(const uint8_t* bytes);
Decoder(device_eventhandler_t report) : report(report) {}
bool decode(std::shared_ptr<Message>& result, const std::shared_ptr<Packet>& packet);