[PATCH 2/3] gtphub: fix number map range for TEIs.

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/OpenBSC@lists.osmocom.org/.

Neels Hofmeyr nhofmeyr at sysmocom.de
Thu Nov 26 16:29:15 UTC 2015


On Wed, Nov 25, 2015 at 08:53:45PM +0100, Holger Freyther wrote:
> > -typedef int nr_t;
> > +typedef unsigned int nr_t;
> 
> use uint32_t here then? and "nr_t" is that clear it refers to a tei?

nr_map is used for both sequence numbers and TEIs with different range
settings. Sequence numbers range from 0..ffff and TEIs from 1..ffffffff.
So nr_t is intended to be more general, but since gtphub is the only scope
using it, unsigned int is enough to fit both number spaces (assuming int
size will never be less than 32 bits...). So nr_t refers to a TEI as soon
as a nr_pool is *used* for a TEI.

> > +	    (unsigned int)nrm->orig, (unsigned int)nrm->repl);
> 
> What is the explicit casting about?

To print values 80000000..ffffffff as positive numbers, the printf format
is using '%u'. Casting to unsigned int it is my preferred way of making
sure the argument matches the printf format...

Might not be necessary, but erases all doubt about intention or type
sizes.

~Neels

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.osmocom.org/pipermail/openbsc/attachments/20151126/aedf50e3/attachment.bin>


More information about the OpenBSC mailing list