aboutsummaryrefslogtreecommitdiffstats
path: root/tests/ms/MsTest.cpp
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-08-28 12:07:14 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-08-28 12:07:14 +0200
commitb6b3c7eb2727da98fbba231d9a1e9fe4a33b2dd0 (patch)
tree8185a122d3012712e44fb4514234d2f414ef2139 /tests/ms/MsTest.cpp
parent1c95bd383e07f0c58805084d36a46d774ea91726 (diff)
tbf: Use explicit initialisations in constructor (Coverity)
Currently when allocating tbf_alloc_ul_tbf or tbf_alloc_dl_tbf objects, the allocated memory area is pre-initialised by talloc_zero before the C++ constructors are called. This is not recognised by Coverity, since there is no talloc model file yet. Thus Coverity complains about missing initialisers. On the other hand, it is still planned to convert the TBF classes into real C++ ones. So instead of silencing Coverity directly, this is an opportunity to do it the C++ way. This commit adds initialisers and initialisation code for all members that relied on talloc_zero. The corresponding calls to talloc_zero are replaced by calls to talloc to give ASAN/valgrind a chance to detect future initialisation errors. Some initialisation code is also moved from setup_tbf to the constructors, notably the initialisation of the bts pointer. Fixes: Coverity CID 1320604, 1320605, 1320606 Sponsored-by: On-Waves ehf
Diffstat (limited to 'tests/ms/MsTest.cpp')
-rw-r--r--tests/ms/MsTest.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/tests/ms/MsTest.cpp b/tests/ms/MsTest.cpp
index 4e9c7e2f..344b0b4a 100644
--- a/tests/ms/MsTest.cpp
+++ b/tests/ms/MsTest.cpp
@@ -55,9 +55,9 @@ static void test_ms_state()
OSMO_ASSERT(ms->is_idle());
dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf);
- new (dl_tbf) gprs_rlcmac_dl_tbf();
+ new (dl_tbf) gprs_rlcmac_dl_tbf(NULL);
ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf);
- new (ul_tbf) gprs_rlcmac_ul_tbf();
+ new (ul_tbf) gprs_rlcmac_ul_tbf(NULL);
ms->attach_tbf(ul_tbf);
OSMO_ASSERT(!ms->is_idle());
@@ -116,9 +116,9 @@ static void test_ms_callback()
OSMO_ASSERT(ms->is_idle());
dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf);
- new (dl_tbf) gprs_rlcmac_dl_tbf();
+ new (dl_tbf) gprs_rlcmac_dl_tbf(NULL);
ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf);
- new (ul_tbf) gprs_rlcmac_ul_tbf();
+ new (ul_tbf) gprs_rlcmac_ul_tbf(NULL);
OSMO_ASSERT(last_cb == UNKNOWN);
@@ -186,11 +186,11 @@ static void test_ms_replace_tbf()
was_idle = false;
dl_tbf[0] = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf);
- new (dl_tbf[0]) gprs_rlcmac_dl_tbf();
+ new (dl_tbf[0]) gprs_rlcmac_dl_tbf(NULL);
dl_tbf[1] = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf);
- new (dl_tbf[1]) gprs_rlcmac_dl_tbf();
+ new (dl_tbf[1]) gprs_rlcmac_dl_tbf(NULL);
ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf);
- new (ul_tbf) gprs_rlcmac_ul_tbf();
+ new (ul_tbf) gprs_rlcmac_ul_tbf(NULL);
ms->attach_tbf(dl_tbf[0]);
OSMO_ASSERT(!ms->is_idle());
@@ -349,7 +349,7 @@ static void test_ms_storage()
printf("=== start %s ===\n", __func__);
ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf);
- new (ul_tbf) gprs_rlcmac_ul_tbf();
+ new (ul_tbf) gprs_rlcmac_ul_tbf(NULL);
ms = store.get_ms(tlli + 0);
OSMO_ASSERT(ms == NULL);
@@ -440,9 +440,9 @@ static void test_ms_timeout()
OSMO_ASSERT(ms->is_idle());
dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf);
- new (dl_tbf) gprs_rlcmac_dl_tbf();
+ new (dl_tbf) gprs_rlcmac_dl_tbf(NULL);
ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf);
- new (ul_tbf) gprs_rlcmac_ul_tbf();
+ new (ul_tbf) gprs_rlcmac_ul_tbf(NULL);
OSMO_ASSERT(last_cb == UNKNOWN);
@@ -498,7 +498,7 @@ static void test_ms_cs_selection()
OSMO_ASSERT(ms->is_idle());
dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf);
- new (dl_tbf) gprs_rlcmac_dl_tbf();
+ new (dl_tbf) gprs_rlcmac_dl_tbf(NULL);
dl_tbf->set_ms(ms);
OSMO_ASSERT(!ms->is_idle());