[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <75f1792c788e418eaddc0d6b7e3381de@SIXPR30MB031.064d.mgd.msft.net>
Date: Thu, 23 Jul 2015 03:05:16 +0000
From: Dexuan Cui <decui@...rosoft.com>
To: Dan Carpenter <dan.carpenter@...cle.com>
CC: Vitaly Kuznetsov <vkuznets@...hat.com>,
"olaf@...fle.de" <olaf@...fle.de>,
"pebolle@...cali.nl" <pebolle@...cali.nl>,
"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
"jasowang@...hat.com" <jasowang@...hat.com>,
"driverdev-devel@...uxdriverproject.org"
<driverdev-devel@...uxdriverproject.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"stephen@...workplumber.org" <stephen@...workplumber.org>,
"stefanha@...hat.com" <stefanha@...hat.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"apw@...onical.com" <apw@...onical.com>,
"davem@...emloft.net" <davem@...emloft.net>
Subject: RE: [PATCH V3 3/7] Drivers: hv: vmbus: add APIs to send/recv hvsock
packet and get the r/w-ability
> 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:
> > > 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists