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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Wed Mar 8 17:08:09 UTC 2017


Patch Set 2:

(1 comment)

https://gerrit.osmocom.org/#/c/2007/2/src/bts.cpp
File src/bts.cpp:

Line 554: 	if (abs((int32_t)rfn - m_cur_rfn) > RFN_THRESHOLD) {
is rfn also limited to 22 bits?
maybe add an OSMO_ASSERT for this / a less aggressive error message with bail out in case (int32_t)rfn would end up negative? (also serves to document beyond doubt what the code expects)

m_cur_rfn is actually an int, which might be like a int64_t. We're not checking its magnitude ... If the first operand is int32_t, the calculation will also take place truncated to int32_t. Sure, this will practically not pose a problem when the numbers are always small enough anyway, but type safety here is still pretty mixed up :)

I guess I'd rather cast to (int)rfn to match m_cur_rfn and make sure the result is never wrapped around some type boundary, for the odd case of erratic m_cur_rfn?

Sorry if I'm nitpicking from a too theoretical viewpoint -- I don't really know this code so I don't trust it to stay within range of int32_t.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib6d895a97aa35414f245ea4406c6e78f1b4fb5b8
Gerrit-PatchSet: 2
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: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
Gerrit-HasComments: Yes



More information about the gerrit-log mailing list