From cc158e7009a87701f3f62e625bf1f0a4c528799c Mon Sep 17 00:00:00 2001 From: Montoli Date: Thu, 8 Mar 2018 14:18:41 -0800 Subject: [PATCH] Swapped the order of two conditions in an assert. (#4663) An assert in flexbuffers was bit-shifting a 64-bit number by 64 bits, which throws up warnings in some automated tools. The same assert also checks to see if the number of bytes being shifted is 8. Swapped the order, so that the bitshift only occurs if the number of bits being shifted is not 64. Should be the same behavior, but plays nicer with diagnostic tools. --- include/flatbuffers/flexbuffers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/flatbuffers/flexbuffers.h b/include/flatbuffers/flexbuffers.h index a25213fdd..1e6e47699 100644 --- a/include/flatbuffers/flexbuffers.h +++ b/include/flatbuffers/flexbuffers.h @@ -1274,7 +1274,7 @@ class Builder FLATBUFFERS_FINAL_CLASS { void WriteOffset(uint64_t o, uint8_t byte_width) { auto reloff = buf_.size() - o; - assert(reloff < 1ULL << (byte_width * 8) || byte_width == 8); + assert(byte_width == 8 || reloff < 1ULL << (byte_width * 8)); Write(reloff, byte_width); }