lkml.org 
[lkml]   [2014]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] pinctrl: Avoid kasprintf/kfree
From
Date
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



\
 
 \ /
  Last update: 2014-02-24 20:01    [W:0.042 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site