diff options
author | Harald Welte <laforge@gnumonks.org> | 2012-06-14 11:51:16 +0800 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2012-06-14 11:51:16 +0800 |
commit | c882b85d8c867264a0fe038dfe34bf204f5e3f32 (patch) | |
tree | 7855728b02962dcdd31819e12f2d7fee19f2c6f2 /src/common/sysinfo.c | |
parent | 565cf0d8ab15282e5f12d74e5e69baff514a6565 (diff) |
system information: avoid modulo 0 / SIGFPE
As Holger pointed out, it may well be the case that there are no system
information messages to be sent at TC=4, and we should avoid a modulo by
0. I'm simply sending SI2 instead now, as it isn't forbidden to send it
more often than the minimum at TC=2...
Diffstat (limited to 'src/common/sysinfo.c')
-rw-r--r-- | src/common/sysinfo.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index 874fb6d9..62d2af9c 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -95,9 +95,14 @@ uint8_t *bts_sysinfo_get(struct gsm_bts *bts, struct gsm_time *g_time) tc4_sub[tc4_cnt] = SYSINFO_TYPE_9; tc4_cnt += 1; } - /* increment static counter by one, modulo count */ - btsb->si.tc4_ctr = (btsb->si.tc4_ctr + 1) % tc4_cnt; - return GSM_BTS_SI(bts, tc4_sub[btsb->si.tc4_ctr]); + /* simply send SI2 if we have nothing else to send */ + if (tc4_cnt == 0) + return GSM_BTS_SI(bts, SYSINFO_TYPE_2); + else { + /* increment static counter by one, modulo count */ + btsb->si.tc4_ctr = (btsb->si.tc4_ctr + 1) % tc4_cnt; + return GSM_BTS_SI(bts, tc4_sub[btsb->si.tc4_ctr]); + } case 5: /* 2bis, 2ter, 2quater */ if (BTS_HAS_SI(bts, SYSINFO_TYPE_2bis) && |