On maandag 31 oktober 2011, Derek Atkins wrote:
> Geert Janssens <[email protected]> writes:
> > -    if(strcmp(order, DEFAULT_SORT_ORDER) != 0)
> > +    if (order && (strcmp (order, DEFAULT_SORT_ORDER) != 0))
> 
> Why not use safe_strcmp()?
> 
> -derek

I could have, but in this case only using safe_strcmp would still yield the 
wrong result. Using safe_strcmp, if order were NULL, then the test would 
evaluate to TRUE (a NULL value is always not equal to a non-null value) and 
the "then" part would be executed. However, in this case if order is NULL, the 
"then" part has to be skipped.

And by the way, I don't see much use for safe_strcmp anymore in gnucash. I'd 
rather user g_strcmp0, which behaves exactly the same, but is part of glibc. 
Our code is heavily dependent on glibc anyway, so I prefer to use its 
convenience functions over maintaining our own.

Geert
_______________________________________________
gnucash-devel mailing list
[email protected]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to