On Tue, Mar 21, 2017 at 01:37:11PM +1100, Tobin C. Harding wrote:
> Comparison, equal to zero, is redundant
> 
> 'if (foo == 0)'  is equal to  'if (!foo)'
> 
> Typical kernel coding style is to use the shorter form.
> 
> Remove unnecessary zero comparison.

Not exactly.  If you're talking about the number zero then == 0 and != 0
are good style.  "if (size == 0) ".  Other times we're talking about
error codes or whatever and not the number zero so it should be
"if (ret) ".  Also for strcmp() functions, please use != 0 and == 0.

        if (strcmp(foo, bar) != 0)  <-- read this as "foo != bar"
        if (strcmp(foo, bar) == 0)  <-- read this as "foo == bar"
        if (strcmp(foo, bar) < 0)  <-- read this as "foo < bar"

regards,
dan carpenter


_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to