[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <53A3FCC0.6050705@codethink.co.uk>
Date: Fri, 20 Jun 2014 10:20:00 +0100
From: Rob Jones <rob.jones@...ethink.co.uk>
To: Joe Perches <joe@...ches.com>
CC: linus.walleij@...aro.org, gnurou@...il.com, lgirdwood@...il.com,
broonie@...nel.org, linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-kernel@...ethink.co.uk,
ian.molton@...ethink.co.uk, ben.dooks@...ethink.co.uk,
heiko@...ech.de
Subject: Re: [PATCH 3/4] drivers/base: devres.c: use devm_kmemdup() from with
devm_kstrdup()
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@...ethink.co.uk>
>> Signed-off-by: Rob Jones <rob.jones@...ethink.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@...ethink.co.uk
tel:+44 161 236 5575
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists