All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH v2] staging/lustre/ptlrpc: Removes potential null dereference
Date: Tue, 17 May 2016 09:53:31 +0300	[thread overview]
Message-ID: <20160517065330.GA10957@mwanda> (raw)
In-Reply-To: <8AEE9006-6CF8-4BB7-A236-808ACE3AB302@intel.com>

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

  parent reply	other threads:[~2016-05-17  6:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-16 14:17 [lustre-devel] [PATCH v2] staging/lustre/ptlrpc: Removes potential null dereference Lidza Louina
2016-05-16 17:57 ` Patrick Farrell
2016-05-16 18:16   ` James Simmons
2016-05-16 18:22     ` Patrick Farrell
2016-05-16 18:25       ` James Simmons
2016-05-16 18:35     ` Dilger, Andreas
2016-05-16 18:47       ` Lidza Louina
2016-05-17  6:53       ` Dan Carpenter [this message]
2016-05-17 14:22         ` Lidza Louina
2016-05-17 16:39           ` 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=20160517065330.GA10957@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=lustre-devel@lists.lustre.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.