[PATCH] osmo-bts[master]: scheduler_trx: Fix signed integer overflow in clock calculat...

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/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Wed Apr 25 13:03:17 UTC 2018


Review at  https://gerrit.osmocom.org/7918

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
---
M src/osmo-bts-trx/scheduler_trx.c
1 file changed, 3 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/18/7918/1

diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index 4a31df2..4c4ae6c 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -1581,7 +1581,7 @@
 	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 @@
 	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

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I36e0d2d0d0c6e35e963f611135453c4a4c00bc99
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list