Re: [lustre-devel] [PATCH v2] staging/lustre/ptlrpc: Removes potential null dereference

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

 



When I read the code, I just assumed desc was a pointer and it should
have been:

	if (!desc)
		return NULL;

For me, "if (rc) " is way more readable than "if (rc != 0) ".  So
readability could go either way depending on what you're used to, I
suppose.

It should definitely == 0 and != 0 if you are talking about the actual
number zero instead of success/fail like we are here.  Also it helps to
use == 0 with strcmp() and friends (although half of the kernel does not
know that trick yet).

The other thing which I have noticed recently is that a lot of
subsystems use a mix of "if (rc) " and "if (rc < 0) ".  It's annoying
for Smatch because say a function only returns zero but the some of the
callers check for < 0 and some check for != 0.  We can't know for sure
that they are equivalent.

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