Re: [PATCH 12/19] staging: lustre: libcfs: remove == 0 testing

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

 



On Thu, Nov 17, 2016 at 02:35:50PM -0500, James Simmons wrote:
> Testing == 0 is not kernel style so remove this
> type of testing from libcfs.
> 

That's not true.  Checkpatch.pl won't complain.

Not everyone has thought about it or agrees with me but there are time
when == 0 is idiomatic.  For example, if you are talking about the
*number* zero then it should probably be == 0.  If it's like "rc == 0"
then "rc" doesn't mean the number it means success/fail so it should be
"if (!rc) ".  But it's intuitive to say "if (len == 0) ".

The other place is strcmp() and friends where it's much more intuitive:

	strcmp(a, b) == 0 means a == b
	strcmp(a, b) < 0 means a < b
	strcmp(a, b) != 0 means a != b

regards,
dan carpenter

_______________________________________________
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