From: Dan Carpenter
Sent: Wednesday, July 22, 2015 18:36
To: Dexuan Cui
On Wed, Jul 22, 2015 at 10:09:10AM +0000, Dexuan Cui wrote:
quoted
quoted
I'd suggest you do something like
if (ret == -EAGIAIN)
return 0;
else if (ret)
return ret;
to make it future-proof (e.g. when a new error is returned by
hv_ringbuffer_peek). And a comment would also be useful as it is unclear
why we silence errors here.
Hi Vitaly,
Thanks!
I think I made a mistake here:
the "if (ret != 0) return 0;" should be changed
to "if (ret != 0) return ret;"
Usually 0 means success to me, so
to me, "ret != 0" reads like "ret is not successful" and seems natural.
The kind of usage is not rare in the kernel code:
decui@lin:~/linux-next$ grep 'if (ret != 0)' kernel/ include/ ipc/ -r | wc -l
28
decui@lin:~/linux-next$ grep 'if (ret != 0)' drivers/ -r | wc -l
1031
The double negative really doesn't not make the code more complicated.
I like using a quadruple negative instead.
if (ret != 0 != 0)
return ret;
dan carpenter
Hi Dan, I read this as a humor. :-)
I'll take the suggestion and remember to use this in V4 and in future:
if (ret)
return ret;
Thanks!
-- Dexuan