All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: octeon: convert all uses of strlcpy to strscpy in ethernet-mdio.c
@ 2021-02-07 14:48 ` Phillip Potter
  0 siblings, 0 replies; 6+ messages in thread
From: Phillip Potter @ 2021-02-07 14:48 UTC (permalink / raw)
  To: gregkh
  Cc: alexander.sverdlin, andrew, davem, chris.packham, devel, linux-kernel

Convert three calls to strlcpy inside the cvm_oct_get_drvinfo function
to strscpy calls. Fixes a style warning.

Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
 drivers/staging/octeon/ethernet-mdio.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c
index b0fd083a5bf2..b3049108edc4 100644
--- a/drivers/staging/octeon/ethernet-mdio.c
+++ b/drivers/staging/octeon/ethernet-mdio.c
@@ -21,9 +21,9 @@
 static void cvm_oct_get_drvinfo(struct net_device *dev,
 				struct ethtool_drvinfo *info)
 {
-	strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
-	strlcpy(info->version, UTS_RELEASE, sizeof(info->version));
-	strlcpy(info->bus_info, "Builtin", sizeof(info->bus_info));
+	strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
+	strscpy(info->version, UTS_RELEASE, sizeof(info->version));
+	strscpy(info->bus_info, "Builtin", sizeof(info->bus_info));
 }
 
 static int cvm_oct_nway_reset(struct net_device *dev)
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] staging: octeon: convert all uses of strlcpy to strscpy in ethernet-mdio.c
@ 2021-02-07 14:48 ` Phillip Potter
  0 siblings, 0 replies; 6+ messages in thread
From: Phillip Potter @ 2021-02-07 14:48 UTC (permalink / raw)
  To: gregkh
  Cc: devel, andrew, linux-kernel, chris.packham, alexander.sverdlin, davem

Convert three calls to strlcpy inside the cvm_oct_get_drvinfo function
to strscpy calls. Fixes a style warning.

Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
 drivers/staging/octeon/ethernet-mdio.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c
index b0fd083a5bf2..b3049108edc4 100644
--- a/drivers/staging/octeon/ethernet-mdio.c
+++ b/drivers/staging/octeon/ethernet-mdio.c
@@ -21,9 +21,9 @@
 static void cvm_oct_get_drvinfo(struct net_device *dev,
 				struct ethtool_drvinfo *info)
 {
-	strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
-	strlcpy(info->version, UTS_RELEASE, sizeof(info->version));
-	strlcpy(info->bus_info, "Builtin", sizeof(info->bus_info));
+	strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
+	strscpy(info->version, UTS_RELEASE, sizeof(info->version));
+	strscpy(info->bus_info, "Builtin", sizeof(info->bus_info));
 }
 
 static int cvm_oct_nway_reset(struct net_device *dev)
-- 
2.29.2

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: octeon: convert all uses of strlcpy to strscpy in ethernet-mdio.c
  2021-02-07 14:48 ` Phillip Potter
@ 2021-02-07 14:55   ` Greg KH
  -1 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2021-02-07 14:55 UTC (permalink / raw)
  To: Phillip Potter
  Cc: alexander.sverdlin, andrew, davem, chris.packham, devel, linux-kernel

On Sun, Feb 07, 2021 at 02:48:04PM +0000, Phillip Potter wrote:
> Convert three calls to strlcpy inside the cvm_oct_get_drvinfo function
> to strscpy calls. Fixes a style warning.

Is it really safe to do this type of conversion here?  If so, you need
to provide evidence of it in the changelog, otherwise we could just do a
search/replace across the whole kernel and be done with it :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: octeon: convert all uses of strlcpy to strscpy in ethernet-mdio.c
@ 2021-02-07 14:55   ` Greg KH
  0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2021-02-07 14:55 UTC (permalink / raw)
  To: Phillip Potter
  Cc: devel, andrew, linux-kernel, chris.packham, alexander.sverdlin, davem

On Sun, Feb 07, 2021 at 02:48:04PM +0000, Phillip Potter wrote:
> Convert three calls to strlcpy inside the cvm_oct_get_drvinfo function
> to strscpy calls. Fixes a style warning.

Is it really safe to do this type of conversion here?  If so, you need
to provide evidence of it in the changelog, otherwise we could just do a
search/replace across the whole kernel and be done with it :)

thanks,

greg k-h
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: octeon: convert all uses of strlcpy to strscpy in ethernet-mdio.c
  2021-02-07 14:55   ` Greg KH
@ 2021-02-07 15:25     ` Joe Perches
  -1 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2021-02-07 15:25 UTC (permalink / raw)
  To: Greg KH, Phillip Potter
  Cc: alexander.sverdlin, andrew, davem, chris.packham, devel, linux-kernel

On Sun, 2021-02-07 at 15:55 +0100, Greg KH wrote:
> On Sun, Feb 07, 2021 at 02:48:04PM +0000, Phillip Potter wrote:
> > Convert three calls to strlcpy inside the cvm_oct_get_drvinfo function
> > to strscpy calls. Fixes a style warning.
> 
> Is it really safe to do this type of conversion here?

Yes.  No locks are taken by either strlcpy or strscpy, and the conversion
is only done where the return value is unused.

strscpy is:

lib/string.c: * Preferred to strlcpy() since the API doesn't require reading memory
lib/string.c- * from the src string beyond the specified "count" bytes, and since
lib/string.c: * the return value is easier to error-check than strlcpy()'s.
lib/string.c- * In addition, the implementation is robust to the string changing out
lib/string.c: * from underneath it, unlike the current strlcpy() implementation.

> If so, you need
> to provide evidence of it in the changelog, otherwise we could just do a
> search/replace across the whole kernel and be done with it :)

Yes please.

There's a cocci script for that in commit 75b1a8f9d62e
("ALSA: Convert strlcpy to strscpy when return value is unused")



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: octeon: convert all uses of strlcpy to strscpy in ethernet-mdio.c
@ 2021-02-07 15:25     ` Joe Perches
  0 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2021-02-07 15:25 UTC (permalink / raw)
  To: Greg KH, Phillip Potter
  Cc: devel, andrew, linux-kernel, chris.packham, alexander.sverdlin, davem

On Sun, 2021-02-07 at 15:55 +0100, Greg KH wrote:
> On Sun, Feb 07, 2021 at 02:48:04PM +0000, Phillip Potter wrote:
> > Convert three calls to strlcpy inside the cvm_oct_get_drvinfo function
> > to strscpy calls. Fixes a style warning.
> 
> Is it really safe to do this type of conversion here?

Yes.  No locks are taken by either strlcpy or strscpy, and the conversion
is only done where the return value is unused.

strscpy is:

lib/string.c: * Preferred to strlcpy() since the API doesn't require reading memory
lib/string.c- * from the src string beyond the specified "count" bytes, and since
lib/string.c: * the return value is easier to error-check than strlcpy()'s.
lib/string.c- * In addition, the implementation is robust to the string changing out
lib/string.c: * from underneath it, unlike the current strlcpy() implementation.

> If so, you need
> to provide evidence of it in the changelog, otherwise we could just do a
> search/replace across the whole kernel and be done with it :)

Yes please.

There's a cocci script for that in commit 75b1a8f9d62e
("ALSA: Convert strlcpy to strscpy when return value is unused")


_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-02-07 15:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-07 14:48 [PATCH] staging: octeon: convert all uses of strlcpy to strscpy in ethernet-mdio.c Phillip Potter
2021-02-07 14:48 ` Phillip Potter
2021-02-07 14:55 ` Greg KH
2021-02-07 14:55   ` Greg KH
2021-02-07 15:25   ` Joe Perches
2021-02-07 15:25     ` Joe Perches

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.