[MERGED] osmo-pcu[master]: Fix dozens of compiler warnings across the board

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Feb 10 12:21:17 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: Fix dozens of compiler warnings across the board
......................................................................


Fix dozens of compiler warnings across the board

Change-Id: I166109dc05d3323b92cd2a42f0c7e6009950e15d
---
M src/pcu_vty.c
M src/tbf.cpp
M tests/alloc/AllocTest.cpp
M tests/bitcomp/BitcompTest.cpp
M tests/edge/EdgeTest.cpp
M tests/llc/LlcTest.cpp
M tests/tbf/TbfTest.cpp
7 files changed, 39 insertions(+), 81 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/pcu_vty.c b/src/pcu_vty.c
index 535d512..3b5996c 100644
--- a/src/pcu_vty.c
+++ b/src/pcu_vty.c
@@ -3,6 +3,7 @@
 
 #include <stdint.h>
 #include <stdlib.h>
+#include <string.h>
 #include <osmocom/vty/logging.h>
 #include <osmocom/vty/stats.h>
 #include <osmocom/vty/misc.h>
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 0d28c5c..820131c 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -171,13 +171,13 @@
 	bts(bts_),
 	m_tfi(0),
 	m_created_ts(0),
+	m_ctrs(NULL),
 	m_ms(NULL),
 	m_ta(GSM48_TA_INVALID),
 	m_ms_class(0),
 	m_list(this),
 	m_ms_list(this),
-	m_egprs_enabled(false),
-	m_ctrs(NULL)
+	m_egprs_enabled(false)
 {
 	/* The classes of these members do not have proper constructors yet.
 	 * Just set them to 0 like talloc_zero did */
@@ -854,9 +854,9 @@
 
 gprs_rlcmac_dl_tbf::BandWidth::BandWidth() :
 	dl_bw_octets(0),
+	dl_throughput(0),
 	dl_loss_lost(0),
-	dl_loss_received(0),
-	dl_throughput(0)
+	dl_loss_received(0)
 {
 	timerclear(&dl_bw_tv);
 	timerclear(&dl_loss_tv);
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index f7794f7..308c802 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -170,7 +170,7 @@
 {
 	for (size_t i = 0; i < ARRAY_SIZE(tbf->pdch); ++i)
 		if (tbf->pdch[i])
-			printf("PDCH[%d] is used for %s\n", i, dir);
+			printf("PDCH[%zu] is used for %s\n", i, dir);
 	printf("PDCH[%d] is control_ts for %s\n", tbf->control_ts, dir);
 	printf("PDCH[%d] is first common for %s\n", tbf->first_common_ts, dir);
 }
diff --git a/tests/bitcomp/BitcompTest.cpp b/tests/bitcomp/BitcompTest.cpp
index fd3b0df..31b6d11 100644
--- a/tests/bitcomp/BitcompTest.cpp
+++ b/tests/bitcomp/BitcompTest.cpp
@@ -121,7 +121,7 @@
 }
 
 /* To verify the result with expected result */
-int check_result(bitvec bits, uint8_t *exp_data, int exp_len)
+int check_result(bitvec bits, uint8_t *exp_data, unsigned int exp_len)
 {
 	if (bits.cur_bit != exp_len)
 		return 0;
@@ -147,7 +147,7 @@
 {
 	bitvec dest;
 	int init_flag = 1;
-	int itr;
+	unsigned int itr;
 	int rc;
 	uint8_t bits_data[RLC_EGPRS_MAX_WS/8];
 
diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp
index 3537aa7..86c08f5 100644
--- a/tests/edge/EdgeTest.cpp
+++ b/tests/edge/EdgeTest.cpp
@@ -40,6 +40,7 @@
 
 #include <errno.h>
 #include <string.h>
+#include <limits.h>
 
 void *tall_pcu_ctx;
 int16_t spoof_mnc = 0, spoof_mcc = 0;
@@ -1001,7 +1002,7 @@
 	OSMO_ASSERT(rdbi.e == 1);
 	OSMO_ASSERT(rdbi.cv == 0);
 	OSMO_ASSERT(write_offset == (int)rdbi.data_len);
-	OSMO_ASSERT(count_payload == rdbi.data_len);
+	OSMO_ASSERT(rdbi.data_len <= INT_MAX && count_payload == (int)rdbi.data_len);
 	OSMO_ASSERT(num_chunks == 1);
 
 	OSMO_ASSERT(data[0] == 0);
@@ -1027,7 +1028,8 @@
 	OSMO_ASSERT(rdbi.e == 0);
 	OSMO_ASSERT(rdbi.cv == 0);
 	OSMO_ASSERT(write_offset == (int)rdbi.data_len);
-	OSMO_ASSERT(count_payload == rdbi.data_len - 1);
+	OSMO_ASSERT((rdbi.data_len - 1) <= INT_MAX
+		    && count_payload == (int)(rdbi.data_len - 1));
 	OSMO_ASSERT(num_chunks == 1);
 
 	OSMO_ASSERT(data[0] == (((rdbi.data_len-1) << 1) | (1 << 0)));
@@ -1054,7 +1056,8 @@
 	OSMO_ASSERT(rdbi.e == 0);
 	OSMO_ASSERT(rdbi.cv == 0);
 	OSMO_ASSERT(write_offset == (int)rdbi.data_len);
-	OSMO_ASSERT(count_payload == rdbi.data_len - 2);
+	OSMO_ASSERT((rdbi.data_len - 2) <= INT_MAX
+		    && count_payload == (int)(rdbi.data_len - 2));
 	OSMO_ASSERT(num_chunks == 2);
 
 	OSMO_ASSERT(data[0] == (((rdbi.data_len-2) << 1) | (0 << 0)));
@@ -1194,16 +1197,12 @@
 	uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta,
 	uint8_t ms_class)
 {
-	GprsMs *ms;
 	struct pcu_l1_meas meas;
 	int tfi = 0;
-	gprs_rlcmac_bts *bts;
-	RlcMacUplink_t ulreq = {0};
 	uint8_t data[79] = {0};
 	struct gprs_rlc_ul_header_egprs_2 *egprs2  = NULL;
 
 	egprs2 = (struct gprs_rlc_ul_header_egprs_2 *) data;
-	bts = the_bts->bts_data();
 
 	tfi = 1;
 
@@ -1288,10 +1287,7 @@
 	uint32_t fn = 2654218;
 	uint16_t qta = 31;
 	uint32_t tlli = 0xf1223344;
-	const char *imsi = "0011223344";
 	uint8_t ms_class = 1;
-	gprs_rlcmac_ul_tbf *ul_tbf;
-	GprsMs *ms;
 
 	printf("=== start %s ===\n", __func__);
 	setup_bts(&the_bts, ts_no, 10);
@@ -1305,18 +1301,14 @@
 	uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta,
 	uint8_t ms_class)
 {
-	uint8_t trx_no = 0;
 	int tfi = 0;
-	struct gprs_rlcmac_pdch *pdch;
-	gprs_rlcmac_bts *bts;
 	uint8_t data[155] = {0};
 	struct gprs_rlc_ul_header_egprs_1 *egprs1  = NULL;
 	struct gprs_rlc_data_info rlc;
 	GprsCodingScheme cs;
-	int rc, offs;
+	int rc;
 
 	egprs1 = (struct gprs_rlc_ul_header_egprs_1 *) data;
-	bts = the_bts->bts_data();
 
 	tfi = 1;
 
@@ -1409,10 +1401,7 @@
 	uint32_t fn = 2654218;
 	uint16_t qta = 31;
 	uint32_t tlli = 0xf1223344;
-	const char *imsi = "0011223344";
 	uint8_t ms_class = 1;
-	gprs_rlcmac_ul_tbf *ul_tbf;
-	GprsMs *ms;
 
 	printf("=== start %s ===\n", __func__);
 	setup_bts(&the_bts, ts_no, 12);
diff --git a/tests/llc/LlcTest.cpp b/tests/llc/LlcTest.cpp
index e972cf4..8df010e 100644
--- a/tests/llc/LlcTest.cpp
+++ b/tests/llc/LlcTest.cpp
@@ -66,7 +66,7 @@
 	llc_msg = queue->dequeue(&info_res);
 	OSMO_ASSERT(llc_msg != NULL);
 
-	fprintf(stderr, "dequeued msg, length %d (expected %d), data %s\n",
+	fprintf(stderr, "dequeued msg, length %u (expected %zu), data %s\n",
 		msgb_length(llc_msg), len, msgb_hexdump(llc_msg));
 
 	OSMO_ASSERT(msgb_length(llc_msg) == len);
@@ -239,7 +239,7 @@
 	if (!tall_pcu_ctx)
 		abort();
 
-	msgb_set_talloc_ctx(tall_pcu_ctx);
+	msgb_talloc_ctx_init(tall_pcu_ctx, 0);
 	osmo_init_logging(&debug_log_info);
 	log_set_use_color(osmo_stderr_target, 0);
 	log_set_print_filename(osmo_stderr_target, 0);
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
index e367ce6..79e49ec 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -633,7 +633,7 @@
 	uint32_t rach_fn = *fn - 51;
 	uint32_t sba_fn = *fn + 52;
 	uint8_t trx_no = 0;
-	int tfi = 0, i = 0;
+	int tfi = 0;
 	gprs_rlcmac_ul_tbf *ul_tbf;
 	struct gprs_rlcmac_pdch *pdch;
 	gprs_rlcmac_bts *bts;
@@ -701,7 +701,7 @@
 	/* send fake data */
 	uint8_t data_msg[42] = {
 		0xf << 2, /* GPRS_RLCMAC_DATA_BLOCK << 6, CV = 15 */
-		tfi << 1,
+		(uint8_t)(tfi << 1),
 		1, /* BSN:7, E:1 */
 	};
 
@@ -1222,17 +1222,14 @@
 	uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta,
 	uint8_t ms_class, uint8_t egprs_ms_class)
 {
-	GprsMs *ms;
 	uint32_t rach_fn = *fn - 51;
 	uint32_t sba_fn = *fn + 52;
 	uint8_t trx_no = 0;
-	int tfi = 0, i = 0;
+	int tfi = 0;
 	gprs_rlcmac_ul_tbf *ul_tbf;
-	struct gprs_rlcmac_pdch *pdch;
 	gprs_rlcmac_bts *bts;
 	RlcMacUplink_t ulreq = {0};
 	struct pcu_l1_meas meas;
-	struct gprs_rlc_ul_header_egprs_3 *egprs3  = NULL;
 	GprsCodingScheme cs;
 
 	meas.set_rssi(31);
@@ -1298,15 +1295,10 @@
 	OSMO_ASSERT(ul_tbf);
 	OSMO_ASSERT(ul_tbf->ta() == qta / 4);
 	GprsMs *ms;
-	uint32_t rach_fn = *fn - 51;
-	uint32_t sba_fn = *fn + 52;
 	uint8_t trx_no = 0;
-	int tfi = 0, i = 0;
+	int tfi = 0;
 	struct gprs_rlcmac_pdch *pdch;
-	gprs_rlcmac_bts *bts;
-	RlcMacUplink_t ulreq = {0};
 	struct pcu_l1_meas meas;
-	struct gprs_rlc_ul_header_egprs_3 *egprs3  = NULL;
 	GprsCodingScheme cs;
 
 
@@ -1386,15 +1378,10 @@
 	OSMO_ASSERT(ul_tbf);
 	OSMO_ASSERT(ul_tbf->ta() == qta / 4);
 	GprsMs *ms;
-	uint32_t rach_fn = *fn - 51;
-	uint32_t sba_fn = *fn + 52;
 	uint8_t trx_no = 0;
-	int tfi = 0, i = 0;
+	int tfi = 0;
 	struct gprs_rlcmac_pdch *pdch;
-	gprs_rlcmac_bts *bts;
-	RlcMacUplink_t ulreq = {0};
 	struct pcu_l1_meas meas;
-	struct gprs_rlc_ul_header_egprs_3 *egprs3  = NULL;
 	GprsCodingScheme cs;
 
 	check_tbf(ul_tbf);
@@ -1473,16 +1460,11 @@
 	uint8_t ms_class, uint8_t egprs_ms_class)
 {
 	GprsMs *ms;
-	uint32_t rach_fn = *fn - 51;
-	uint32_t sba_fn = *fn + 52;
 	uint8_t trx_no = 0;
-	int tfi = 0, i = 0;
+	int tfi = 0;
 	gprs_rlcmac_ul_tbf *ul_tbf;
 	struct gprs_rlcmac_pdch *pdch;
-	gprs_rlcmac_bts *bts;
-	RlcMacUplink_t ulreq = {0};
 	struct pcu_l1_meas meas;
-	struct gprs_rlc_ul_header_egprs_3 *egprs3  = NULL;
 	GprsCodingScheme cs;
 
 
@@ -1918,7 +1900,7 @@
 	fprintf(stderr, "Got '%s', TA=%d\n", ul_tbf->name(), ul_tbf->ta());
 
 	send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"RAU_ACCEPT", 10);
-	fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n",
+	fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n",
 		ms1->tlli(), ms1->ta(), ms1->imsi(), ms1->llc_queue()->size());
 
 	/* Send Packet Downlink Assignment to MS */
@@ -1941,7 +1923,7 @@
 	/* The PCU cannot know yet, that both TBF belong to the same MS */
 	OSMO_ASSERT(ms1 != ms2);
 
-	fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n",
+	fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n",
 		ms1->tlli(), ms1->ta(), ms1->imsi(), ms1->llc_queue()->size());
 
 	/* Send some downlink data along with the new TLLI and the IMSI so that
@@ -1951,7 +1933,7 @@
 	ms = the_bts.ms_by_imsi(imsi);
 	OSMO_ASSERT(ms == ms2);
 
-	fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n",
+	fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n",
 		ms2->tlli(), ms2->ta(), ms2->imsi(), ms2->llc_queue()->size());
 
 	ms = the_bts.ms_by_tlli(tlli1);
@@ -1987,7 +1969,7 @@
 
 	send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"DATA 1 *************", 20);
 	send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"DATA 2 *************", 20);
-	fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n",
+	fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n",
 		ms1->tlli(), ms1->ta(), ms1->imsi(), ms1->llc_queue()->size());
 
 	OSMO_ASSERT(ms1->llc_queue()->size() == 2);
@@ -2004,7 +1986,7 @@
 		ms_class, 0);
 
 	ms2 = ul_tbf->ms();
-	fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n",
+	fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n",
 		ms2->tlli(), ms2->ta(), ms2->imsi(), ms2->llc_queue()->size());
 
 	/* This should be the same MS object */
@@ -2048,7 +2030,7 @@
 
 	send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"DATA 1 *************", 20);
 	send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"DATA 2 *************", 20);
-	fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n",
+	fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n",
 		ms1->tlli(), ms1->ta(), ms1->imsi(), ms1->llc_queue()->size());
 
 	OSMO_ASSERT(ms1->llc_queue()->size() == 2);
@@ -2064,7 +2046,7 @@
 	ul_tbf = establish_ul_tbf_single_phase(&the_bts, ts_no, tlli1, &fn, qta);
 
 	ms2 = ul_tbf->ms();
-	fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n",
+	fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n",
 		ms2->tlli(), ms2->ta(), ms2->imsi(), ms2->llc_queue()->size());
 
 	/* There should be a different MS object */
@@ -2119,7 +2101,7 @@
 		send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)buf, rc);
 	}
 
-	fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n",
+	fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n",
 		ms1->tlli(), ms1->ta(), ms1->imsi(), ms1->llc_queue()->size());
 
 	/* Send Packet Downlink Assignment to MS */
@@ -2370,7 +2352,7 @@
 	uint32_t rach_fn = *fn - 51;
 	uint32_t sba_fn = *fn + 52;
 	uint8_t trx_no = 0;
-	int tfi = 0, i = 0;
+	int tfi = 0;
 	gprs_rlcmac_ul_tbf *ul_tbf;
 	struct gprs_rlcmac_pdch *pdch;
 	gprs_rlcmac_bts *bts;
@@ -2742,12 +2724,9 @@
 	unsigned i;
 	uint8_t ms_class = 11;
 	uint8_t egprs_ms_class = 11;
-	uint32_t fn = 0;
 	uint8_t trx_no;
 	uint32_t tlli = 0xffeeddcc;
 	uint8_t test_data[512];
-
-	uint8_t rbb[64/8];
 
 	gprs_rlcmac_dl_tbf *dl_tbf;
 
@@ -2777,7 +2756,6 @@
 
 static void tbf_cleanup(gprs_rlcmac_dl_tbf *dl_tbf)
 {
-	uint32_t fn = 0;
 	uint8_t rbb[64/8];
 
 	/* Receive a final ACK */
@@ -2792,19 +2770,16 @@
 }
 
 static void egprs_spb_to_normal_validation(BTS *the_bts,
-		int mcs, int demanded_mcs)
+		unsigned int mcs, unsigned int demanded_mcs)
 {
 	uint32_t fn = 0;
 	gprs_rlcmac_dl_tbf *dl_tbf;
-	uint8_t block_nr = 0;
-	int index1 = 0;
-	uint8_t bn;
 	uint16_t bsn1, bsn2, bsn3;
 	struct msgb *msg;
 	struct gprs_rlc_dl_header_egprs_3 *egprs3;
 	struct gprs_rlc_dl_header_egprs_2 *egprs2;
 
-	printf("Testing retx for MCS %d to reseg_mcs %d\n", mcs, demanded_mcs);
+	printf("Testing retx for MCS %u to reseg_mcs %u\n", mcs, demanded_mcs);
 
 	dl_tbf = tbf_init(the_bts, mcs);
 
@@ -2886,18 +2861,16 @@
 
 	tbf_cleanup(dl_tbf);
 }
+
 static void establish_and_use_egprs_dl_tbf_for_spb(BTS *the_bts,
-		int mcs, int demanded_mcs)
+		unsigned int mcs, unsigned int demanded_mcs)
 {
 	uint32_t fn = 0;
 	gprs_rlcmac_dl_tbf *dl_tbf;
-	uint8_t block_nr = 0;
-	int index1 = 0;
-	uint8_t bn;
 	struct msgb *msg;
 	struct gprs_rlc_dl_header_egprs_3 *egprs3;
 
-	printf("Testing retx for MCS %d to reseg_mcs %d\n", mcs, demanded_mcs);
+	printf("Testing retx for MCS %u to reseg_mcs %u\n", mcs, demanded_mcs);
 
 	dl_tbf = tbf_init(the_bts, mcs);
 
@@ -2989,16 +2962,13 @@
 }
 
 static void establish_and_use_egprs_dl_tbf_for_retx(BTS *the_bts,
-		int mcs, int demanded_mcs)
+		unsigned int mcs, unsigned int demanded_mcs)
 {
 	uint32_t fn = 0;
 	gprs_rlcmac_dl_tbf *dl_tbf;
-	uint8_t block_nr = 0;
-	int index1 = 0;
-	uint8_t bn;
 	struct msgb *msg;
 
-	printf("Testing retx for MCS %d - %d\n", mcs, demanded_mcs);
+	printf("Testing retx for MCS %u - %u\n", mcs, demanded_mcs);
 
 	dl_tbf = tbf_init(the_bts, mcs);
 
@@ -3137,7 +3107,6 @@
 	BTS the_bts;
 	gprs_rlcmac_bts *bts;
 	uint8_t ts_no = 4;
-	int i, j;
 
 	printf("=== start %s ===\n", __func__);
 
@@ -3167,7 +3136,6 @@
 	BTS the_bts;
 	gprs_rlcmac_bts *bts;
 	uint8_t ts_no = 4;
-	int i, j;
 
 	printf("=== start %s ===\n", __func__);
 

-- 
To view, visit https://gerrit.osmocom.org/1771
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I166109dc05d3323b92cd2a42f0c7e6009950e15d
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list