mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
To: Maninder Singh <maninder1.s@samsung.com>
Cc: "lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"broonie@kernel.org" <broonie@kernel.org>,
	"patches@opensource.wolfsonmicro.com" 
	<patches@opensource.wolfsonmicro.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	PANKAJ MISHRA <pankaj.m@samsung.com>
Subject: Re: [PATCH v2] regulator: wm831x-dcdc: Use pointer after NULL check
Date: Thu, 2 Jul 2015 12:12:13 +0100	[thread overview]
Message-ID: <20150702111213.GC16517@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1041654268.190401435834974293.JavaMail.weblogic@ep2mlwas01a>

On Thu, Jul 02, 2015 at 11:02:54AM +0000, Maninder Singh wrote:
> Hello charles,
> >> pdata is used before NULL check, so it looks misleading.
> >> If pdata validation is required then we have to
> >> first check for pdata validation, then calculate id,
> >> and then second check for pdata->dcdc[id].
> >> 
> >> and it is better to use !pointer than (pointer == NULL)
> >> 
> >> Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
> >> ---
> 
> >The patch basically looks fine, but it feels a bit like needless
> >churn. The current code is perfectly correct and feels clear
> >enough to me.
> 
> Reason for patch is we are checking a pointer which is already dereferenced 
> before NULL check, which looks misleading.
> If we know code is working correctly, Then we may simply drop NULL check,
> rather than these changes. 

You can't drop the NULL check because then we might dereference a
NULL pointer. ARRAY_SIZE(pdata->dcdc) is perfectly save because
sizeof only works on types so no actual dereference takes place.

Thanks,
Charles

  reply	other threads:[~2015-07-02 11:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-02 11:02 Maninder Singh
2015-07-02 11:12 ` Charles Keepax [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-07-02  7:57 Maninder Singh
2015-07-02 10:18 ` Charles Keepax
2015-07-02 11:14   ` Mark Brown
2015-07-02 11:19     ` Charles Keepax
2015-07-02 11:33       ` Mark Brown

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=20150702111213.GC16517@opensource.wolfsonmicro.com \
    --to=ckeepax@opensource.wolfsonmicro.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maninder1.s@samsung.com \
    --cc=pankaj.m@samsung.com \
    --cc=patches@opensource.wolfsonmicro.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

Powered by JetHome