aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/pcu_vty.c1
-rw-r--r--src/tbf.cpp8
-rw-r--r--tests/alloc/AllocTest.cpp2
-rw-r--r--tests/bitcomp/BitcompTest.cpp4
-rw-r--r--tests/edge/EdgeTest.cpp25
-rw-r--r--tests/llc/LlcTest.cpp4
-rw-r--r--tests/tbf/TbfTest.cpp76
7 files changed, 39 insertions, 81 deletions
diff --git a/src/pcu_vty.c b/src/pcu_vty.c
index 535d512b..3b5996c8 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 0d28c5c1..820131c7 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -171,13 +171,13 @@ gprs_rlcmac_tbf::gprs_rlcmac_tbf(BTS *bts_, gprs_rlcmac_tbf_direction dir) :
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 @@ struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts,
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 f7794f7c..308c8028 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -170,7 +170,7 @@ static void dump_assignment(struct gprs_rlcmac_tbf *tbf, const char *dir)
{
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 fd3b0dfa..31b6d115 100644
--- a/tests/bitcomp/BitcompTest.cpp
+++ b/tests/bitcomp/BitcompTest.cpp
@@ -121,7 +121,7 @@ static int filter_fn(const struct log_context *ctx,
}
/* 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 @@ static void test_EPDAN_decode_tree(void)
{
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 3537aa72..86c08f5a 100644
--- a/tests/edge/EdgeTest.cpp
+++ b/tests/edge/EdgeTest.cpp
@@ -40,6 +40,7 @@ extern "C" {
#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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void uplink_header_type_2_parsing_test(BTS *the_bts,
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 @@ static void uplink_header_type2_test(void)
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 @@ static void uplink_header_type_1_parsing_test(BTS *the_bts,
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 @@ void uplink_header_type1_test(void)
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 e972cf4e..8df010e8 100644
--- a/tests/llc/LlcTest.cpp
+++ b/tests/llc/LlcTest.cpp
@@ -66,7 +66,7 @@ static void dequeue_and_check(gprs_llc_queue *queue, const uint8_t *exp_data,
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 @@ int main(int argc, char **argv)
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 e367ce6c..79e49ec1 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -633,7 +633,7 @@ static gprs_rlcmac_ul_tbf *puan_urbb_len_issue(BTS *the_bts,
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 @@ static gprs_rlcmac_ul_tbf *puan_urbb_len_issue(BTS *the_bts,
/* 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 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf(BTS *the_bts,
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 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_puan_URBB_no_length(BTS *t
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 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_puan_URBB_with_length(BTS
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 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_puan_CRBB(BTS *the_bts,
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 @@ static void test_tbf_ra_update_rach()
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 @@ static void test_tbf_ra_update_rach()
/* 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 @@ static void test_tbf_ra_update_rach()
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 @@ static void test_tbf_dl_flow_and_rach_two_phase()
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 @@ static void test_tbf_dl_flow_and_rach_two_phase()
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 @@ static void test_tbf_dl_flow_and_rach_single_phase()
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 @@ static void test_tbf_dl_flow_and_rach_single_phase()
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 @@ static void test_tbf_dl_reuse()
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 @@ static gprs_rlcmac_ul_tbf *tbf_li_decoding(BTS *the_bts,
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,13 +2724,10 @@ static gprs_rlcmac_dl_tbf *tbf_init(BTS *the_bts,
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;
memset(test_data, 1, sizeof(test_data));
@@ -2777,7 +2756,6 @@ static gprs_rlcmac_dl_tbf *tbf_init(BTS *the_bts,
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 tbf_cleanup(gprs_rlcmac_dl_tbf *dl_tbf)
}
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 @@ static void egprs_spb_to_normal_validation(BTS *the_bts,
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_spb(BTS *the_bts,
}
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 @@ static void test_tbf_egprs_retx_dl(void)
BTS the_bts;
gprs_rlcmac_bts *bts;
uint8_t ts_no = 4;
- int i, j;
printf("=== start %s ===\n", __func__);
@@ -3167,7 +3136,6 @@ static void test_tbf_egprs_spb_dl(void)
BTS the_bts;
gprs_rlcmac_bts *bts;
uint8_t ts_no = 4;
- int i, j;
printf("=== start %s ===\n", __func__);