[webkit-dev] strcmp result checking
simon.fraser at apple.com
Thu Dec 17 09:24:50 PST 2009
On Dec 16, 2009, at 10:02 PM, Peter Kasting wrote:
> On Wed, Dec 16, 2009 at 9:12 PM, Alexey Proskuryakov <ap at webkit.org> wrote:
> As current style rules say that tests for zero/non-zero should all be done without equality comparisons. However, this rule can cause significant readability problems if blindly applied to strcmp: if (!strcmp(string, "foobar")) naturally reads as "does not equal".
> I have always found !strcmp() to be more readable than the == 0 form, rather than less. I don't have a logical explanation for this, it just reads as "if strcmp didn't find differences" to me.
> I definitely wish we'd be consistent in our usage whichever way people agree on.
The better solution here would be to have an inline function strequal() that returns a bool, and use that instead of strcmp() when testing for equality.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev