lkml.org 
[lkml]   [2018]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v1 2/7] extcon: Switch to use kasprintf() instead of open coded
Date
From: Andy Shevchenko
> Sent: 27 August 2018 16:36
>
> Switch to use kasprintf() instead of open coded variant.
> No functional change intended.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/extcon/extcon.c | 13 +++----------
> 1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
> index c21650a92689..5ab0498be652 100644
> --- a/drivers/extcon/extcon.c
> +++ b/drivers/extcon/extcon.c
> @@ -1123,7 +1123,6 @@ int extcon_dev_register(struct extcon_dev *edev)
> (unsigned long)atomic_inc_return(&edev_no));
>
> if (edev->max_supported) {
> - char buf[10];
> char *str;
> struct extcon_cable *cable;
>
> @@ -1137,9 +1136,7 @@ int extcon_dev_register(struct extcon_dev *edev)
> for (index = 0; index < edev->max_supported; index++) {
> cable = &edev->cables[index];
>
> - snprintf(buf, 10, "cable.%d", index);
> - str = kzalloc(strlen(buf) + 1,
> - GFP_KERNEL);
> + str = kasprintf(GFP_KERNEL, "cable.%d", index);

Hmmm... Why now just allocate the space for the string in the
'extcon_cable' structure.
(Then work out how to stop gcc complaining there isn't room
for 4G cables ...)

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

\
 
 \ /
  Last update: 2018-08-29 11:39    [W:1.030 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site