aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-02-21 14:33:15 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-02-21 14:40:16 +0100
commit00727558a95a9063857b0767b33588f07605df2d (patch)
tree4167fa100366533f4efdc86b77ac6b6cd0a2fff8 /tests
parent162a3fe5dd7f327d192b2df08e61249a2adc45b5 (diff)
HO: fix minor issues found by coverity
handover_decision_2: - lchan->conn should never be NULL, but if it is, don't crash in LOGPHO* macros. - make certain to avoid modulo-zero. It's cosmetic since that config item is not allowed to be zero. handover_test: - check return value of gsm_generate_si(). - safer evaluation of main()'s argv. Fixes: CID#182929, CID#182928, CID#182927, CID#182926 Change-Id: I68e8ed3a1e8659edb47ac3e8a10508f17a3f5670
Diffstat (limited to 'tests')
-rw-r--r--tests/handover/handover_test.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/tests/handover/handover_test.c b/tests/handover/handover_test.c
index e8716f2d2..d1f75ba4e 100644
--- a/tests/handover/handover_test.c
+++ b/tests/handover/handover_test.c
@@ -1223,7 +1223,6 @@ static char **test_cases[] = {
test_case_26,
test_case_27,
test_case_28,
- NULL
};
static const struct log_info_cat log_categories[] = {
@@ -1269,21 +1268,21 @@ int main(int argc, char **argv)
int bts_num = 0;
struct gsm_lchan *lchan[256];
int lchan_num = 0;
- int test_count = 0;
int i;
int algorithm;
struct bsc_api bsc_api = {};
+ int test_case_i;
+ int last_test_i;
- for (i = 0; test_cases[i]; i++)
- test_count++;
+ test_case_i = argc > 1? atoi(argv[1]) : -1;
+ last_test_i = ARRAY_SIZE(test_cases) - 1;
- if (argc <= 1 || atoi(argv[1]) >= test_count) {
- for (i = 0; test_cases[i]; i++) {
+ if (test_case_i < 0 || test_case_i > last_test_i) {
+ for (i = 0; i <= last_test_i; i++) {
printf("Test #%d (algorithm %s):\n%s\n", i,
test_cases[i][0], test_cases[i][1]);
}
- printf("\nPlease specify test case number 0..%d\n",
- test_count - 1);
+ printf("\nPlease specify test case number 0..%d\n", last_test_i);
return EXIT_FAILURE;
}
@@ -1320,11 +1319,11 @@ int main(int argc, char **argv)
bts_model_sysmobts_init();
- test_case = test_cases[atoi(argv[1])];
+ test_case = test_cases[test_case_i];
fprintf(stderr, "--------------------\n");
fprintf(stderr, "Performing the following test %d (algorithm %s):\n%s",
- atoi(argv[1]), test_case[0], test_case[1]);
+ test_case_i, test_case[0], test_case[1]);
algorithm = atoi(test_case[0]);
test_case += 2;
fprintf(stderr, "--------------------\n");
@@ -1343,9 +1342,10 @@ int main(int argc, char **argv)
"TS(1-4) are TCH/F, TS(5-6) are TCH/H)\n", n);
for (i = 0; i < n; i++)
bts[bts_num + i] = create_bts(arfcn++);
- for (i = 0; i < n; i++)
- gsm_generate_si(bts[bts_num + i],
- SYSINFO_TYPE_2);
+ for (i = 0; i < n; i++) {
+ if (gsm_generate_si(bts[bts_num + i], SYSINFO_TYPE_2))
+ fprintf(stderr, "Error generating SI2\n");
+ }
bts_num += n;
test_case += 2;
} else