* [PATCH] mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy
@ 2017-02-03 9:49 Arnd Bergmann
2017-02-04 21:12 ` Marek Vasut
0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2017-02-03 9:49 UTC (permalink / raw)
To: Brian Norris
Cc: Arnd Bergmann, David Woodhouse, Boris Brezillon, Marek Vasut,
Richard Weinberger, Cyrille Pitchen, linux-mtd, linux-kernel
kernelci.org reports a warning for this driver, as it copies a local
variable into a 'const char *' string:
drivers/mtd/maps/pmcmsp-flash.c:149:30: warning: passing argument 1 of 'strncpy' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
Using kstrndup() simplifies the code and avoids the warning.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/mtd/maps/pmcmsp-flash.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/mtd/maps/pmcmsp-flash.c b/drivers/mtd/maps/pmcmsp-flash.c
index f9fa3fad728e..2051f28ddac6 100644
--- a/drivers/mtd/maps/pmcmsp-flash.c
+++ b/drivers/mtd/maps/pmcmsp-flash.c
@@ -139,15 +139,13 @@ static int __init init_msp_flash(void)
}
msp_maps[i].bankwidth = 1;
- msp_maps[i].name = kmalloc(7, GFP_KERNEL);
+ msp_maps[i].name = kstrndup(flash_name, 7, GFP_KERNEL);
if (!msp_maps[i].name) {
iounmap(msp_maps[i].virt);
kfree(msp_parts[i]);
goto cleanup_loop;
}
- msp_maps[i].name = strncpy(msp_maps[i].name, flash_name, 7);
-
for (j = 0; j < pcnt; j++) {
part_name[5] = '0' + i;
part_name[7] = '0' + j;
--
2.9.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy
2017-02-03 9:49 [PATCH] mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy Arnd Bergmann
@ 2017-02-04 21:12 ` Marek Vasut
2017-02-08 21:16 ` Brian Norris
0 siblings, 1 reply; 4+ messages in thread
From: Marek Vasut @ 2017-02-04 21:12 UTC (permalink / raw)
To: Arnd Bergmann, Brian Norris
Cc: David Woodhouse, Boris Brezillon, Richard Weinberger,
Cyrille Pitchen, linux-mtd, linux-kernel
On 02/03/2017 10:49 AM, Arnd Bergmann wrote:
> kernelci.org reports a warning for this driver, as it copies a local
> variable into a 'const char *' string:
>
> drivers/mtd/maps/pmcmsp-flash.c:149:30: warning: passing argument 1 of 'strncpy' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
>
> Using kstrndup() simplifies the code and avoids the warning.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Marek Vasut <marek.vasut@gmail.com>
> ---
> drivers/mtd/maps/pmcmsp-flash.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/maps/pmcmsp-flash.c b/drivers/mtd/maps/pmcmsp-flash.c
> index f9fa3fad728e..2051f28ddac6 100644
> --- a/drivers/mtd/maps/pmcmsp-flash.c
> +++ b/drivers/mtd/maps/pmcmsp-flash.c
> @@ -139,15 +139,13 @@ static int __init init_msp_flash(void)
> }
>
> msp_maps[i].bankwidth = 1;
> - msp_maps[i].name = kmalloc(7, GFP_KERNEL);
> + msp_maps[i].name = kstrndup(flash_name, 7, GFP_KERNEL);
> if (!msp_maps[i].name) {
> iounmap(msp_maps[i].virt);
> kfree(msp_parts[i]);
> goto cleanup_loop;
> }
>
> - msp_maps[i].name = strncpy(msp_maps[i].name, flash_name, 7);
> -
> for (j = 0; j < pcnt; j++) {
> part_name[5] = '0' + i;
> part_name[7] = '0' + j;
>
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy
2017-02-04 21:12 ` Marek Vasut
@ 2017-02-08 21:16 ` Brian Norris
0 siblings, 0 replies; 4+ messages in thread
From: Brian Norris @ 2017-02-08 21:16 UTC (permalink / raw)
To: Marek Vasut
Cc: Arnd Bergmann, David Woodhouse, Boris Brezillon,
Richard Weinberger, Cyrille Pitchen, linux-mtd, linux-kernel
On Sat, Feb 04, 2017 at 10:12:35PM +0100, Marek Vasut wrote:
> On 02/03/2017 10:49 AM, Arnd Bergmann wrote:
> > kernelci.org reports a warning for this driver, as it copies a local
> > variable into a 'const char *' string:
> >
> > drivers/mtd/maps/pmcmsp-flash.c:149:30: warning: passing argument 1 of 'strncpy' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
> >
> > Using kstrndup() simplifies the code and avoids the warning.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Acked-by: Marek Vasut <marek.vasut@gmail.com>
Applied to l2-mtd.git.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy
@ 2016-09-10 19:57 Arnd Bergmann
0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2016-09-10 19:57 UTC (permalink / raw)
To: Brian Norris
Cc: kernel-build-reports, Arnd Bergmann, David Woodhouse, linux-mtd,
linux-kernel
kernelci.org reports a warning for this driver, as it copies a local
variable into a 'const char *' string:
drivers/mtd/maps/pmcmsp-flash.c:149:30: warning: passing argument 1 of 'strncpy' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
Using kstrndup() simplifies the code and avoids the warning.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/mtd/maps/pmcmsp-flash.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/mtd/maps/pmcmsp-flash.c b/drivers/mtd/maps/pmcmsp-flash.c
index 744ca5cacc9b..cf54420f943d 100644
--- a/drivers/mtd/maps/pmcmsp-flash.c
+++ b/drivers/mtd/maps/pmcmsp-flash.c
@@ -139,15 +139,13 @@ static int __init init_msp_flash(void)
}
msp_maps[i].bankwidth = 1;
- msp_maps[i].name = kmalloc(7, GFP_KERNEL);
+ msp_maps[i].name = kstrndup(flash_name, 7, GFP_KERNEL);
if (!msp_maps[i].name) {
iounmap(msp_maps[i].virt);
kfree(msp_parts[i]);
goto cleanup_loop;
}
- msp_maps[i].name = strncpy(msp_maps[i].name, flash_name, 7);
-
for (j = 0; j < pcnt; j++) {
part_name[5] = '0' + i;
part_name[7] = '0' + j;
--
2.9.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-02-08 21:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-03 9:49 [PATCH] mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy Arnd Bergmann
2017-02-04 21:12 ` Marek Vasut
2017-02-08 21:16 ` Brian Norris
-- strict thread matches above, loose matches on Subject: below --
2016-09-10 19:57 Arnd Bergmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.