diff options
author | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-01-06 15:40:35 -0500 |
---|---|---|
committer | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-01-06 15:40:35 -0500 |
commit | 05e7cb6cfd0929046abe0ea44bab7a43d7f6d0d2 (patch) | |
tree | df81b774fcc895f1f8c0152bfbd6b64a9256405c /src | |
parent | 6f243098abadbde2e9b2e5b13a94029960ea2e51 (diff) |
Watch for an error when getting a bit field.
Diffstat (limited to 'src')
-rw-r--r-- | src/bitfield/bitfield.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/bitfield/bitfield.c b/src/bitfield/bitfield.c index b244c9b1..795f0208 100644 --- a/src/bitfield/bitfield.c +++ b/src/bitfield/bitfield.c @@ -36,10 +36,13 @@ uint64_t get_bitfield(const uint8_t source[], const uint8_t source_length, ArrayOrBytes combined; memset(combined.bytes, 0, sizeof(combined.bytes)); - copy_bits_right_aligned(source, source_length, offset, bit_count, - combined.bytes, sizeof(combined.bytes)); - if(BYTE_ORDER == LITTLE_ENDIAN) { - combined.whole = __builtin_bswap64(combined.whole); + if(copy_bits_right_aligned(source, source_length, offset, bit_count, + combined.bytes, sizeof(combined.bytes))) { + if(BYTE_ORDER == LITTLE_ENDIAN) { + combined.whole = __builtin_bswap64(combined.whole); + } + } else { + // debug("couldn't copy enough bits from source") } return combined.whole; } |