[PATCH 09/10] staging: ks7010: remove zero comparison
Dan Carpenter
dan.carpenter at oracle.com
Wed Mar 22 09:34:23 UTC 2017
On Wed, Mar 22, 2017 at 10:22:24AM +1100, Tobin C. Harding wrote:
> 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) {
The second one.
regards,
dan carpenter
More information about the devel
mailing list