mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Mark Brown <broonie@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	linaro-kernel <linaro-kernel@lists.linaro.org>,
	Mark Brown <broonie@linaro.org>
Subject: Re: [PATCH] pinctrl: Avoid kasprintf/kfree
Date: Mon, 24 Feb 2014 10:16:25 -0800	[thread overview]
Message-ID: <1393265785.11020.40.camel@joe-AO722> (raw)
In-Reply-To: <CACRpkdYxDu-vZLpc3Ef-2q1B3wpHqnuJofRwhA332Qw4pw39vg@mail.gmail.com>

On Mon, 2014-02-24 at 10:49 +0100, Linus Walleij wrote:
> On Thu, Jan 30, 2014 at 9:37 PM, Joe Perches <joe@perches.com> wrote:
> > Avoid an unnecessary allocation/free by using stack instead.
> >
> > Signed-off-by; Joe Perches <joe@perches.com>
> 
> Hm.
> 
> > +       char propname[9 + sizeof(int) * 2 + 4] = "pinctrl-";
> 
> If you absolutely want to do this you have to
> 
> #define PINCTRL_PREFIX "pinctrl-"
> 
> char propname[strlen(PINCTRL_PREFIX) + sizeof(int)*2 + 4] = PINCTRL_PREFIX;
> 
> Then add a comment above stating why you add 4.

No, I don't really.

> > This allocation seems unnecessary and the kasprintf isn't
> > checked for non-null, so maybe this is better.
> 
> Another option would be to just add a NULL-check? This is
> definately not on a performance-critical path.

It's a defect not to check the kasprintf return before
writing through it.

I submitted what I think appropriate.

Fix it as you choose.  Or not.

cheers, Joe


  reply	other threads:[~2014-02-24 18:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-30 18:57 [PATCH] pinctrl: Quiet logging about missing DT nodes when not using DT Mark Brown
2014-01-30 19:04 ` Joe Perches
2014-01-30 20:37   ` [PATCH] pinctrl: Avoid kasprintf/kfree Joe Perches
2014-01-30 20:50     ` Mark Brown
2014-02-24  9:49     ` Linus Walleij
2014-02-24 18:16       ` Joe Perches [this message]
2014-02-24  9:45 ` [PATCH] pinctrl: Quiet logging about missing DT nodes when not using DT Linus Walleij

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=1393265785.11020.40.camel@joe-AO722 \
    --to=joe@perches.com \
    --cc=broonie@kernel.org \
    --cc=broonie@linaro.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.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 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®