I know what !strcmp(s1, s2) means, but I dislike it.
Many functions return a logically Boolean result, even if the result
isn't of type bool or _Bool. By "logically Boolean", I mean that
the result answers a yes/no question without adding more information.
strcmp is not one of those functions, so I dislike using its result
either as a condition or as the operand of "!". For much the same
reason, I dislike writing "if (ptr)" and strongly prefer "if (ptr != NULL)".
I agree on strcmp, partly because it's ternary (as you note
downthread) but I think mostly because 'compare' doesn't connote to me
which case is true. If it had been named strunequal or strdifferent --
still returning 0 for equal and >0 or <0 for the two different types
of unequal -- I would be happy to write it as a pseudo-boolean in the
cases where I only care about equal/unequal, which I estimate is well
over half, and write the >0 or <0 only when I care about direction.
But those names would have been too long in PDP-11 days; strdiff works
for me about as well as memcpy, but struneq just looks silly.
OTOH I disagree about pointers. Maybe it's a fair bit of LISPing, but
the first attribute I think of about almost any pointer, regardless of
target type, is possible nullness. I find ptr or !ptr natural, but I'm
also fine with !=NULL and ==NULL if the style uses that.
But of course that wasn't the point of the question. Using a different
example, would you even consider writing
if (5 == strlen(s))
rather than
if (strlen(s) == 5)
if it weren't for the "==" vs. "=" issue?
Probably not for a simple case like that, and the first 2 or 3 times I
read such it did slow me up a bit before I got used to it.
But if s is more complicated -- maybe if enough to put the ==5 way to
the right and definitely if enough to put it on a subsequent line -- I
would be much more likely to keep the 5 'up front'. OTOH in those
cases I might consider doing the complicated part in a separate
assignment and reducing it to the simple case -- at least for if;
comparable cases in while and for are harder.