From c62c93464779acddc2d516a2dd4d1317f408be8e Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Sun, 15 Apr 2018 23:31:47 +0200 Subject: 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 --- tests/gsm0808/gsm0808_test.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/gsm0808') 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); -- cgit v1.2.3