diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-07-29 16:44:22 +0200 |
---|---|---|
committer | pespin <pespin@sysmocom.de> | 2019-07-30 12:51:29 +0000 |
commit | 2605ffc3d70a7cf0be5828cc565d4d270a317a81 (patch) | |
tree | c90faf78a1eae24689f40fa12d425807d894c7f8 /src/sim/reader_pcsc.c | |
parent | 5c4b9850c21009f20042b1e3920e602f6f6df30f (diff) |
gsm0808_test: Fix wrong use of memcp
After recent system upgrade, gcc 9.1.0, I started getting gsm0808_test
failing locally:
Assert failed memcmp(&enc_ct, &dec_ct, sizeof(enc_ct)) == 0 libosmocore/tests/gsm0808/gsm0808_test.c:992
During investigation with gdb, fields of both structures seem to contain
same values. However, closer lookup gives some hints on why it fails:
(gdb) print memcmp(&enc_ct, &dec_ct, sizeof(enc_ct))
$1 = 85
(gdb) print memcmp(&enc_ct, &dec_ct, 12)
$14 = 85
(gdb) print ((uint8_t*)&enc_ct)[11]
$15 = 85 'U'
(gdb) print ((uint8_t*)&dec_ct)[11]
$16 = 0 '\000'
So the 12th byte in struct gsm0808_channel_type is basically an
alignment padding byte added by the compiler (to align perm_spch_len to
4-byte alignment). Since both compared structs are initialized without
memset(0) but using compiler's designated initializers, it seems the compiler
decided it's no longer needed to zero the padding byte, making memcp fail in
this case.
In order to avoid the failure, let's properly check every field instead
of using memcp here.
Change-Id: I17fe7a0a5dc650f050bba1f47d071be749550729
Diffstat (limited to 'src/sim/reader_pcsc.c')
0 files changed, 0 insertions, 0 deletions