From c23abf4a1a0bbe838b1d4f541922afc0079d7947 Mon Sep 17 00:00:00 2001 From: Scott Dixon Date: Tue, 4 Jun 2024 13:37:13 -0700 Subject: [PATCH] Looks like there's something else going on --- src/nunavut/lang/c/support/serialization.j2 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/nunavut/lang/c/support/serialization.j2 b/src/nunavut/lang/c/support/serialization.j2 index 70d0e547..786f1004 100644 --- a/src/nunavut/lang/c/support/serialization.j2 +++ b/src/nunavut/lang/c/support/serialization.j2 @@ -363,9 +363,9 @@ static inline uint8_t nunavutGetU8(const uint8_t* const buf, const {{ typename_unsigned_bit_length }} bits = {# -#} nunavutSaturateBufferFragmentBitLength(buf_size_bytes, off_bits, nunavutChooseMin(len_bits, 8U)); {{ assert('bits <= (sizeof(uint8_t) * 8U)') }} - uint8_t val = 0; - nunavutCopyBits(&val, 0U, bits, buf, off_bits); - return val; + uint8_t val[2] = {0}; + nunavutCopyBits(&val[0], 0U, bits, buf, off_bits); + return val[0]; } static inline uint16_t nunavutGetU16(const uint8_t* const buf, @@ -382,7 +382,7 @@ static inline uint16_t nunavutGetU16(const uint8_t* const buf, nunavutCopyBits(&val, 0U, bits, buf, off_bits); return val; {%- elif options.target_endianness in ('any', 'big') %} - uint8_t tmp[sizeof(uint16_t)] = {0}; + uint8_t tmp[sizeof(uint16_t) + 1] = {0}; nunavutCopyBits(&tmp[0], 0U, bits, buf, off_bits); return (uint16_t)(tmp[0] | (uint16_t)(((uint16_t) tmp[1]) << 8U)); {%- else %}{%- assert False %} @@ -403,7 +403,7 @@ static inline uint32_t nunavutGetU32(const uint8_t* const buf, nunavutCopyBits(&val, 0U, bits, buf, off_bits); return val; {%- elif options.target_endianness in ('any', 'big') %} - uint8_t tmp[sizeof(uint32_t)] = {0}; + uint8_t tmp[sizeof(uint32_t) + 1] = {0}; nunavutCopyBits(&tmp[0], 0U, bits, buf, off_bits); return (uint32_t)(tmp[0] | ((uint32_t) tmp[1] << 8U) | ((uint32_t) tmp[2] << 16U) | ((uint32_t) tmp[3] << 24U)); {%- else %}{%- assert False %} @@ -424,7 +424,7 @@ static inline uint64_t nunavutGetU64(const uint8_t* const buf, nunavutCopyBits(&val, 0U, bits, buf, off_bits); return val; {%- elif options.target_endianness in ('any', 'big') %} - uint8_t tmp[sizeof(uint64_t)] = {0}; + uint8_t tmp[sizeof(uint64_t) + 1] = {0}; nunavutCopyBits(&tmp[0], 0U, bits, buf, off_bits); return (uint64_t)(tmp[0] | ((uint64_t) tmp[1] << 8U) |