[PATCH 6/6] Introduce a standard way for printing a subscriber's info.

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

Alexander Chemeris alexander.chemeris at gmail.com
Fri Oct 4 10:46:40 UTC 2013


Alex,

On Fri, Oct 4, 2013 at 8:58 AM, Alex Badea <vamposdecampos at gmail.com> wrote:
> On Fri, Oct 4, 2013 at 3:42 AM, Alexander Chemeris
> <alexander.chemeris at gmail.com> wrote:
>> +#define GSM_SUBS_FMT_STR "IMSI %s (id %llu, ext %s%s%s)"
>> +#define GSM_SUBS_FMT_VAL(x) (x)->imsi, (x)->id, (x)->extension, \
>> +    strlen((x)->name)?", name ":"", strlen((x)->name)?(x)->name:""
>
> Checking for an empty string might be done by testing *s or s[0]
> instead of strlen(s).

I was thinking about this and decided for strlen(), because it's more
human readable. But on the second look I think s[0] is not too bad.
Thank you for bringing this up.

> Also the second check for an empty string is superfluous, since it'll
> print the same either way.

Good catch, thanks.

> So one might write that as:
>
> #define GSM_SUBS_FMT_VAL(x) (x)->imsi, (x)->id, (x)->extension, \
>     (x)->name[0] ? ", name " : "", (x)->name

I'll use this for the second iteration of the patch.

-- 
Regards,
Alexander Chemeris.
CEO, Fairwaves LLC / ООО УмРадио
http://fairwaves.ru




More information about the OpenBSC mailing list