[PATCH] osmo-pcu[master]: Fix overloading ambiguity

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

Max gerrit-no-reply at lists.osmocom.org
Thu Mar 9 16:52:04 UTC 2017


Hello dexter, Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/2007

to look at the new patch set (#6).

Fix overloading ambiguity

Fix error introduced in 1275a3f91a744e011b0dba82b09124d249c7abb5 by
using signed 32 bit integer which is enough for Frame Number in
GSM (added assert for max FN as well).

The error was:
bts.cpp: In member function ‘uint32_t BTS::rfn_to_fn(uint32_t)’:
bts.cpp:554:25: error: call of overloaded ‘abs(uint32_t)’ is ambiguous
  if (abs(rfn - m_cur_rfn) > RFN_THRESHOLD) {
                         ^
In file included from /usr/include/c++/6/cstdlib:75:0,
                 from /usr/include/c++/6/stdlib.h:36,
                 from /usr/include/osmocom/core/linuxrbtree.h:97,
                 from /usr/include/osmocom/core/timer.h:35,
                 from ./bts.h:29,
                 from bts.cpp:21:
/usr/include/stdlib.h:735:12: note: candidate: int abs(int)
 extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
            ^~~
In file included from /usr/include/c++/6/stdlib.h:36:0,
                 from /usr/include/osmocom/core/linuxrbtree.h:97,
                 from /usr/include/osmocom/core/timer.h:35,
                 from ./bts.h:29,
                 from bts.cpp:21:
/usr/include/c++/6/cstdlib:185:3: note: candidate: __int128 std::abs(__int128)
   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
   ^~~
/usr/include/c++/6/cstdlib:180:3: note: candidate: long long int std::abs(long long int)
   abs(long long __x) { return __builtin_llabs (__x); }
   ^~~
/usr/include/c++/6/cstdlib:172:3: note: candidate: long int std::abs(long int)
   abs(long __i) { return __builtin_labs(__i); }

Change-Id: Ib6d895a97aa35414f245ea4406c6e78f1b4fb5b8
---
M src/bts.cpp
M src/bts.h
2 files changed, 9 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/07/2007/6

diff --git a/src/bts.cpp b/src/bts.cpp
index 548d000..a370030 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -521,11 +521,15 @@
 }
 
 /* Determine the full frame number from a relative frame number */
-uint32_t BTS::rfn_to_fn(uint32_t rfn)
+uint32_t BTS::rfn_to_fn(int32_t rfn)
 {
-	uint32_t m_cur_rfn;
-	uint32_t fn;
-	uint32_t fn_rounded;
+	int32_t m_cur_rfn;
+	int32_t fn;
+	int32_t fn_rounded;
+
+	/* double-check that relative FN is not negative and fits into int32_t */
+	OSMO_ASSERT(rfn < GSM_MAX_FN);
+	OSMO_ASSERT(rfn >= 0);
 
 	/* Note: If a BTS is sending in a rach request it will be fully aware
 	 * of the frame number. If the PCU is used in a BSC-co-located setup.
diff --git a/src/bts.h b/src/bts.h
index 5d8dc59..78ed002 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -350,7 +350,7 @@
 	uint8_t is_single_block(uint16_t ra, enum ph_burst_type burst_type,
 		uint8_t is_11bit, uint16_t *ms_class, uint16_t *priority);
 
-	uint32_t rfn_to_fn(uint32_t rfn);
+	uint32_t rfn_to_fn(int32_t rfn);
 	int rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, uint8_t is_11bit,
 		enum ph_burst_type burst_type);
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib6d895a97aa35414f245ea4406c6e78f1b4fb5b8
Gerrit-PatchSet: 6
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>



More information about the gerrit-log mailing list