diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-04-25 15:00:46 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-04-25 15:00:50 +0200 |
commit | c45a04bf5884411ee423e688cf69fe2044db0298 (patch) | |
tree | b19184924d57f53307acc616975f07093ac30db8 | |
parent | c7b206e850751f4dda95d038e618d387a5986f8d (diff) |
scheduler_trx: Fix signed integer overflow in clock calculations
Should fix following observed run time errors:
osmo-bts-trx/scheduler_trx.c:1627:65: runtime error: signed integer overflow: -1081823 * 4615 cannot be represented in type 'int'
osmo-bts-trx/scheduler_trx.c:1627:21: runtime error: signed integer overflow: 1852394502 - -697645849 cannot be represented in type 'int'
Related: OS#3213
Change-Id: I36e0d2d0d0c6e35e963f611135453c4a4c00bc99
-rw-r--r-- | src/osmo-bts-trx/scheduler_trx.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c index 4a31df2f..4c4ae6c5 100644 --- a/src/osmo-bts-trx/scheduler_trx.c +++ b/src/osmo-bts-trx/scheduler_trx.c @@ -1581,7 +1581,7 @@ int trx_sched_clock(struct gsm_bts *bts, uint32_t fn) struct osmo_trx_clock_state *tcs = &g_clk_s; struct timespec tv_now; int elapsed_us, elapsed_fn; - int elapsed_us_since_clk, elapsed_fn_since_clk, error_us_since_clk; + int64_t elapsed_us_since_clk, elapsed_fn_since_clk, error_us_since_clk; unsigned int fn_caught_up = 0; const struct timespec interval = { .tv_sec = 0, .tv_nsec = FRAME_DURATION_nS }; @@ -1625,7 +1625,8 @@ int trx_sched_clock(struct gsm_bts *bts, uint32_t fn) elapsed_fn_since_clk = compute_elapsed_fn(tcs->last_clk_ind.fn, fn); /* error (delta) between local clock since last CLK and CLK based on FN clock at TRX */ error_us_since_clk = elapsed_us_since_clk - (FRAME_DURATION_uS * elapsed_fn_since_clk); - LOGP(DL1C, LOGL_INFO, "TRX Clock Ind: elapsed_us=%7d, elapsed_fn=%3d, error_us=%+5d\n", + LOGP(DL1C, LOGL_INFO, "TRX Clock Ind: elapsed_us=%7"PRId64", " + "elapsed_fn=%3"PRId64", error_us=%+5"PRId64"\n", elapsed_us_since_clk, elapsed_fn_since_clk, error_us_since_clk); /* TODO: put this computed error_us_since_clk into some filter |