Alex,
On Fri, Oct 4, 2013 at 8:58 AM, Alex Badea vamposdecampos@gmail.com wrote:
On Fri, Oct 4, 2013 at 3:42 AM, Alexander Chemeris alexander.chemeris@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.