Re: [PATCH 09/10] staging: ks7010: remove zero comparison

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux