Skip to content

Commit

Permalink
Looks like there's something else going on
Browse files Browse the repository at this point in the history
  • Loading branch information
thirtytwobits committed Jun 4, 2024
1 parent bb8ff57 commit c23abf4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/nunavut/lang/c/support/serialization.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 %}
Expand All @@ -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 %}
Expand All @@ -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) |
Expand Down

0 comments on commit c23abf4

Please sign in to comment.