On Tue, Mar 21, 2017 at 03:49:22PM +0300, Dan Carpenter wrote:
> 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
>
>
What is best for flags please?
- if (dwrq->flags == 0) {
+ if (!dwrq->flags) {
thanks,
Tobin.
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel