mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dexuan Cui <decui@microsoft.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>,
	"olaf@aepfle.de" <olaf@aepfle.de>,
	"pebolle@tiscali.nl" <pebolle@tiscali.nl>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"jasowang@redhat.com" <jasowang@redhat.com>,
	"driverdev-devel@linuxdriverproject.org" 
	<driverdev-devel@linuxdriverproject.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stephen@networkplumber.org" <stephen@networkplumber.org>,
	"stefanha@redhat.com" <stefanha@redhat.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"apw@canonical.com" <apw@canonical.com>,
	"davem@davemloft.net" <davem@davemloft.net>
Subject: RE: [PATCH V3 3/7] Drivers: hv: vmbus: add APIs to send/recv hvsock packet and get the r/w-ability
Date: Thu, 23 Jul 2015 03:05:16 +0000	[thread overview]
Message-ID: <75f1792c788e418eaddc0d6b7e3381de@SIXPR30MB031.064d.mgd.msft.net> (raw)
In-Reply-To: <20150722103546.GO5371@mwanda>

> 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


  reply	other threads:[~2015-07-23  3:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-21 10:58 Dexuan Cui
2015-07-21 14:07 ` Vitaly Kuznetsov
2015-07-22 10:09   ` Dexuan Cui
2015-07-22 10:35     ` Dan Carpenter
2015-07-23  3:05       ` Dexuan Cui [this message]
2015-07-23 10:10         ` Dan Carpenter
2015-07-23 10:24           ` Dan Carpenter
2015-07-23 11:05             ` Dexuan Cui
2015-07-24  6:27             ` Sudip Mukherjee
2015-07-24  8:33               ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=75f1792c788e418eaddc0d6b7e3381de@SIXPR30MB031.064d.mgd.msft.net \
    --to=decui@microsoft.com \
    --cc=apw@canonical.com \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olaf@aepfle.de \
    --cc=pebolle@tiscali.nl \
    --cc=stefanha@redhat.com \
    --cc=stephen@networkplumber.org \
    --cc=vkuznets@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®