aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gsm0808/gsm0808_test.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-04-15 23:31:47 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-04-15 23:40:19 +0200
commitc62c93464779acddc2d516a2dd4d1317f408be8e (patch)
tree53afb188a57ddce940ca30a945d0d3178fe3c04b /tests/gsm0808/gsm0808_test.c
parentdb2fa4e0d5a112adedf17948a73b481c69022e14 (diff)
test_gsm0808_enc_dec_speech_codec_with_cfg: initialize properly
The uninitialized members of enc_sc sporadically hit address sanitizer failure during gsm0808_test, like: ../../../../src/libosmocore/src/gsm/gsm0808_utils.c:187:8: runtime error: load of value 13, which is not a valid value for type '_Bool' ../../../../src/libosmocore/src/gsm/gsm0808_utils.c:191:8: runtime error: load of value 119, which is not a valid value for type '_Bool' How the test survived so long is a mystery to me; as soon as some uninitialized members would by coincidence not be zero, the test should always have failed at OSMO_ASSERT(memcmp(&enc_sc, &dec_sc, sizeof(enc_sc)) == 0). Related: OS#3148 Change-Id: Iaa20c59f624fbdc69a018cabd0f7e9c5a1389519
Diffstat (limited to 'tests/gsm0808/gsm0808_test.c')
-rw-r--r--tests/gsm0808/gsm0808_test.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index a9ab72bc..49673fe4 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -595,17 +595,17 @@ static void test_gsm0808_enc_dec_speech_codec()
static void test_gsm0808_enc_dec_speech_codec_with_cfg()
{
- struct gsm0808_speech_codec enc_sc;
- struct gsm0808_speech_codec dec_sc;
+ struct gsm0808_speech_codec enc_sc = {
+ .pi = true,
+ .tf = true,
+ .type = GSM0808_SCT_FR3,
+ .cfg = 0xabcd,
+ };
+ struct gsm0808_speech_codec dec_sc = {};
struct msgb *msg;
uint8_t rc_enc;
int rc_dec;
- enc_sc.pi = true;
- enc_sc.tf = true;
- enc_sc.type = GSM0808_SCT_FR3;
- enc_sc.cfg = 0xabcd;
-
msg = msgb_alloc(1024, "output buffer");
rc_enc = gsm0808_enc_speech_codec(msg, &enc_sc);
OSMO_ASSERT(rc_enc == 5);