linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Jones <rob.jones@codethink.co.uk>
To: Joe Perches <joe@perches.com>
Cc: linus.walleij@linaro.org, gnurou@gmail.com, lgirdwood@gmail.com,
	broonie@kernel.org, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-kernel@codethink.co.uk,
	ian.molton@codethink.co.uk, ben.dooks@codethink.co.uk,
	heiko@sntech.de
Subject: Re: [PATCH 3/4] drivers/base: devres.c: use devm_kmemdup() from with devm_kstrdup()
Date: Fri, 20 Jun 2014 10:20:00 +0100	[thread overview]
Message-ID: <53A3FCC0.6050705@codethink.co.uk> (raw)
In-Reply-To: <1403193567.7875.4.camel@joe-AO725>


On 19/06/14 16:59, Joe Perches wrote:
> On Thu, 2014-06-19 at 16:46 +0100, Rob Jones wrote:
>> Avoid code duplication by using devm_kmemdup() to copy data instead
>> of having a separate loop within devm_kstrdup().
>>
>> Reviewed-by: Ian Molton <ian.molton@codethink.co.uk>
>> Signed-off-by: Rob Jones <rob.jones@codethink.co.uk>
> []
>> diff --git a/drivers/base/devres.c b/drivers/base/devres.c
> []
>> @@ -802,17 +802,10 @@ EXPORT_SYMBOL_GPL(devm_kmalloc);
>>    */
>>   char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp)
>>   {
> []
>> +	return devm_kmemdup(dev, s, (strlen(s) + 1), gfp);
>>   }
>>   EXPORT_SYMBOL_GPL(devm_kstrdup);
> Making this static inline in the header and dropping
> EXPORT_SYMBOL_GPL might be smaller code.
>
> static inline
> char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp)
> {
> 	return devm_kmemdup(dev, s, strlen(s) + 1, gfp);
> }
>

Is it wise not to check for (s == NULL)? Surely the behaviour of 
strlen(NULL) is undefined.

Consequently, I am, on balance, against making the function static 
inline. Given that inline is only a recommendation to the compiler, it 
may well not inline it anyway if the NULL test is present, in which case 
we would end up with a copy of the code in each module that uses it 
rather than a single, global, copy. If it didn't need the NULL test, I 
would agree that it would be best as a static inline but I think it does 
need it.

-- 
Rob Jones
Project Manager
Codethink Ltd
mailto:rob.jones@codethink.co.uk
tel:+44 161 236 5575


  reply	other threads:[~2014-06-20  9:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-19 15:46 Change gpio-reulator-probe() to use managed resources Rob Jones
2014-06-19 15:46 ` [PATCH 1/4] drivers/gpio: devres.c: allow gpio array requests for managed devices Rob Jones
2014-06-20 22:29   ` [Linux-kernel] " Ben Hutchings
2014-06-19 15:46 ` [PATCH 2/4] drivers/base: devres.c: Add block copy func. " Rob Jones
2014-06-20 22:31   ` Ben Hutchings
2014-06-19 15:46 ` [PATCH 3/4] drivers/base: devres.c: use devm_kmemdup() from with devm_kstrdup() Rob Jones
2014-06-19 15:59   ` Joe Perches
2014-06-20  9:20     ` Rob Jones [this message]
2014-06-19 15:46 ` [PATCH 4/4] drivers/regulator: gpio-regulator.c: use managed resources for probe Rob Jones
2014-06-19 17:57 ` Change gpio-reulator-probe() to use managed resources Mark Brown
2014-06-20  8:38   ` Rob Jones
2014-06-20 10:20     ` 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=53A3FCC0.6050705@codethink.co.uk \
    --to=rob.jones@codethink.co.uk \
    --cc=ben.dooks@codethink.co.uk \
    --cc=broonie@kernel.org \
    --cc=gnurou@gmail.com \
    --cc=heiko@sntech.de \
    --cc=ian.molton@codethink.co.uk \
    --cc=joe@perches.com \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@codethink.co.uk \
    --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;
as well as URLs for NNTP newsgroup(s).