linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] Convert all users of strlcpy to strscpy
@ 2021-01-31 17:28 Kumar Kartikeya Dwivedi
  2021-01-31 17:28 ` [PATCH 01/13] staging: comedi: Switch from " Kumar Kartikeya Dwivedi
                   ` (12 more replies)
  0 siblings, 13 replies; 18+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-01-31 17:28 UTC (permalink / raw)
  To: devel, gregkh, linux-kernel
  Cc: Kumar Kartikeya Dwivedi, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Stephen Rothwell, Andrew Morton, Florian Fainelli, William Cohen,
	Mike Rapoport, Thomas Gleixner, Robert Richter, Al Viro,
	greybus-dev, ac100, linux-tegra, linux-fbdev

This series converts all existing users of strlcpy in drivers/staging to use
strscpy instead.

strlcpy is marked as deprecated in Documentation/process/deprecated.rst, and
there is no functional difference when the caller expects truncation (when not
checking the return value). strscpy is relatively better as it also avoids
scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")

The conversions were performed in two steps:

1. The following coccinelle script was used to identify and replace call sites
that expect truncation.

$ spatch --sp-file strscpy.cocci --include-headers --dir --in-place drivers/staging

@strscpy@
expression dest, src, size;
@@
-strlcpy(dest, src, size);
+strscpy(dest, src, size);

2. Each individual automated conversion was rechecked manually for correctness.

Kumar Kartikeya Dwivedi (13):
  staging: comedi: Switch from strlcpy to strscpy
  staging: greybus: Switch from strlcpy to strscpy
  staging: fsl-dpaa2: Switch from strlcpy to strscpy
  staging: most: Switch from strlcpy to strscpy
  staging: nvec: Switch from strlcpy to strscpy
  staging: octeon: Switch from strlcpy to strscpy
  staging: olpc_dcon: Switch from strlcpy to strscpy
  staging: rtl8188eu: Switch from strlcpy to strscpy
  staging: rtl8192e: Switch from strlcpy to strscpy
  staging: rtl8192u: Switch from strlcpy to strscpy
  staging: rtl8712: Switch from strlcpy to strscpy
  staging: sm750fb: Switch from strlcpy to strscpy
  staging: wimax: Switch from strlcpy to strscpy

 drivers/staging/comedi/comedi_fops.c                      | 4 ++--
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c           | 6 +++---
 drivers/staging/greybus/audio_helper.c                    | 2 +-
 drivers/staging/greybus/audio_module.c                    | 2 +-
 drivers/staging/greybus/audio_topology.c                  | 6 +++---
 drivers/staging/greybus/power_supply.c                    | 2 +-
 drivers/staging/greybus/spilib.c                          | 4 ++--
 drivers/staging/most/sound/sound.c                        | 2 +-
 drivers/staging/most/video/video.c                        | 6 +++---
 drivers/staging/nvec/nvec_ps2.c                           | 4 ++--
 drivers/staging/octeon/ethernet-mdio.c                    | 6 +++---
 drivers/staging/olpc_dcon/olpc_dcon.c                     | 2 +-
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c            | 2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_ethtool.c           | 6 +++---
 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c | 2 +-
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c             | 2 +-
 drivers/staging/sm750fb/sm750.c                           | 2 +-
 drivers/staging/wimax/i2400m/netdev.c                     | 6 +++---
 drivers/staging/wimax/i2400m/usb.c                        | 4 ++--
 19 files changed, 35 insertions(+), 35 deletions(-)

-- 
2.29.2


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

* [PATCH 01/13] staging: comedi: Switch from strlcpy to strscpy
  2021-01-31 17:28 [PATCH 00/13] Convert all users of strlcpy to strscpy Kumar Kartikeya Dwivedi
@ 2021-01-31 17:28 ` Kumar Kartikeya Dwivedi
  2021-01-31 17:28 ` [PATCH 02/13] staging: greybus: " Kumar Kartikeya Dwivedi
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-01-31 17:28 UTC (permalink / raw)
  To: devel, gregkh, linux-kernel
  Cc: Kumar Kartikeya Dwivedi, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Stephen Rothwell, Andrew Morton, Al Viro, William Cohen,
	Florian Fainelli, Mike Rapoport, Thomas Gleixner, Robert Richter,
	greybus-dev, ac100, linux-tegra, linux-fbdev

strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
and there is no functional difference when the caller expects truncation
(when not checking the return value). strscpy is relatively better as it
also avoids scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 drivers/staging/comedi/comedi_fops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 80d74cce2..df77b6bf5 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -939,8 +939,8 @@ static int do_devinfo_ioctl(struct comedi_device *dev,
 	/* fill devinfo structure */
 	devinfo.version_code = COMEDI_VERSION_CODE;
 	devinfo.n_subdevs = dev->n_subdevices;
-	strlcpy(devinfo.driver_name, dev->driver->driver_name, COMEDI_NAMELEN);
-	strlcpy(devinfo.board_name, dev->board_name, COMEDI_NAMELEN);
+	strscpy(devinfo.driver_name, dev->driver->driver_name, COMEDI_NAMELEN);
+	strscpy(devinfo.board_name, dev->board_name, COMEDI_NAMELEN);
 
 	s = comedi_file_read_subdevice(file);
 	if (s)
-- 
2.29.2


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

* [PATCH 02/13] staging: greybus: Switch from strlcpy to strscpy
  2021-01-31 17:28 [PATCH 00/13] Convert all users of strlcpy to strscpy Kumar Kartikeya Dwivedi
  2021-01-31 17:28 ` [PATCH 01/13] staging: comedi: Switch from " Kumar Kartikeya Dwivedi
@ 2021-01-31 17:28 ` Kumar Kartikeya Dwivedi
  2021-02-16 14:54   ` Alex Elder
  2021-01-31 17:28 ` [PATCH 03/13] staging: fsl-dpaa2: " Kumar Kartikeya Dwivedi
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 18+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-01-31 17:28 UTC (permalink / raw)
  To: devel, gregkh, linux-kernel
  Cc: Kumar Kartikeya Dwivedi, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Stephen Rothwell, Andrew Morton, Florian Fainelli, Al Viro,
	William Cohen, Mike Rapoport, Thomas Gleixner, Robert Richter,
	greybus-dev, ac100, linux-tegra, linux-fbdev

strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
and there is no functional difference when the caller expects truncation
(when not checking the return value). strscpy is relatively better as it
also avoids scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 drivers/staging/greybus/audio_helper.c   | 2 +-
 drivers/staging/greybus/audio_module.c   | 2 +-
 drivers/staging/greybus/audio_topology.c | 6 +++---
 drivers/staging/greybus/power_supply.c   | 2 +-
 drivers/staging/greybus/spilib.c         | 4 ++--
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c
index 3011b8abc..1ed4772d2 100644
--- a/drivers/staging/greybus/audio_helper.c
+++ b/drivers/staging/greybus/audio_helper.c
@@ -166,7 +166,7 @@ static int gbaudio_remove_controls(struct snd_card *card, struct device *dev,
 			snprintf(id.name, sizeof(id.name), "%s %s", prefix,
 				 control->name);
 		else
-			strlcpy(id.name, control->name, sizeof(id.name));
+			strscpy(id.name, control->name, sizeof(id.name));
 		id.numid = 0;
 		id.iface = control->iface;
 		id.device = control->device;
diff --git a/drivers/staging/greybus/audio_module.c b/drivers/staging/greybus/audio_module.c
index a243d60f0..0f9fdc077 100644
--- a/drivers/staging/greybus/audio_module.c
+++ b/drivers/staging/greybus/audio_module.c
@@ -342,7 +342,7 @@ static int gb_audio_probe(struct gb_bundle *bundle,
 	/* inform above layer for uevent */
 	dev_dbg(dev, "Inform set_event:%d to above layer\n", 1);
 	/* prepare for the audio manager */
-	strlcpy(desc.name, gbmodule->name, GB_AUDIO_MANAGER_MODULE_NAME_LEN);
+	strscpy(desc.name, gbmodule->name, GB_AUDIO_MANAGER_MODULE_NAME_LEN);
 	desc.vid = 2; /* todo */
 	desc.pid = 3; /* todo */
 	desc.intf_id = gbmodule->dev_id;
diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c
index 662e3e8b4..e816e4db5 100644
--- a/drivers/staging/greybus/audio_topology.c
+++ b/drivers/staging/greybus/audio_topology.c
@@ -200,7 +200,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol,
 			return -EINVAL;
 		name = gbaudio_map_controlid(module, data->ctl_id,
 					     uinfo->value.enumerated.item);
-		strlcpy(uinfo->value.enumerated.name, name, NAME_SIZE);
+		strscpy(uinfo->value.enumerated.name, name, NAME_SIZE);
 		break;
 	default:
 		dev_err(comp->dev, "Invalid type: %d for %s:kcontrol\n",
@@ -1047,7 +1047,7 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module,
 	}
 
 	/* Prefix dev_id to widget control_name */
-	strlcpy(temp_name, w->name, NAME_SIZE);
+	strscpy(temp_name, w->name, NAME_SIZE);
 	snprintf(w->name, NAME_SIZE, "GB %d %s", module->dev_id, temp_name);
 
 	switch (w->type) {
@@ -1169,7 +1169,7 @@ static int gbaudio_tplg_process_kcontrols(struct gbaudio_module_info *module,
 		}
 		control->id = curr->id;
 		/* Prefix dev_id to widget_name */
-		strlcpy(temp_name, curr->name, NAME_SIZE);
+		strscpy(temp_name, curr->name, NAME_SIZE);
 		snprintf(curr->name, NAME_SIZE, "GB %d %s", module->dev_id,
 			 temp_name);
 		control->name = curr->name;
diff --git a/drivers/staging/greybus/power_supply.c b/drivers/staging/greybus/power_supply.c
index ec96f2888..75cb170e0 100644
--- a/drivers/staging/greybus/power_supply.c
+++ b/drivers/staging/greybus/power_supply.c
@@ -449,7 +449,7 @@ static int __gb_power_supply_set_name(char *init_name, char *name, size_t len)
 
 	if (!strlen(init_name))
 		init_name = "gb_power_supply";
-	strlcpy(name, init_name, len);
+	strscpy(name, init_name, len);
 
 	while ((ret < len) && (psy = power_supply_get_by_name(name))) {
 		power_supply_put(psy);
diff --git a/drivers/staging/greybus/spilib.c b/drivers/staging/greybus/spilib.c
index fc27c52de..672d540d3 100644
--- a/drivers/staging/greybus/spilib.c
+++ b/drivers/staging/greybus/spilib.c
@@ -455,10 +455,10 @@ static int gb_spi_setup_device(struct gb_spilib *spi, u8 cs)
 	dev_type = response.device_type;
 
 	if (dev_type == GB_SPI_SPI_DEV)
-		strlcpy(spi_board.modalias, "spidev",
+		strscpy(spi_board.modalias, "spidev",
 			sizeof(spi_board.modalias));
 	else if (dev_type == GB_SPI_SPI_NOR)
-		strlcpy(spi_board.modalias, "spi-nor",
+		strscpy(spi_board.modalias, "spi-nor",
 			sizeof(spi_board.modalias));
 	else if (dev_type == GB_SPI_SPI_MODALIAS)
 		memcpy(spi_board.modalias, response.name,
-- 
2.29.2


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

* [PATCH 03/13] staging: fsl-dpaa2: Switch from strlcpy to strscpy
  2021-01-31 17:28 [PATCH 00/13] Convert all users of strlcpy to strscpy Kumar Kartikeya Dwivedi
  2021-01-31 17:28 ` [PATCH 01/13] staging: comedi: Switch from " Kumar Kartikeya Dwivedi
  2021-01-31 17:28 ` [PATCH 02/13] staging: greybus: " Kumar Kartikeya Dwivedi
@ 2021-01-31 17:28 ` Kumar Kartikeya Dwivedi
  2021-01-31 17:28 ` [PATCH 04/13] staging: most: " Kumar Kartikeya Dwivedi
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-01-31 17:28 UTC (permalink / raw)
  To: devel, gregkh, linux-kernel
  Cc: Kumar Kartikeya Dwivedi, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Stephen Rothwell, Andrew Morton, Al Viro, Florian Fainelli,
	Mike Rapoport, William Cohen, Thomas Gleixner, Robert Richter,
	greybus-dev, ac100, linux-tegra, linux-fbdev

strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
and there is no functional difference when the caller expects truncation
(when not checking the return value). strscpy is relatively better as it
also avoids scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c
index d7f4ed1df..0af2e9914 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c
@@ -38,19 +38,19 @@ static void dpaa2_switch_get_drvinfo(struct net_device *netdev,
 	u16 version_major, version_minor;
 	int err;
 
-	strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver));
+	strscpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver));
 
 	err = dpsw_get_api_version(port_priv->ethsw_data->mc_io, 0,
 				   &version_major,
 				   &version_minor);
 	if (err)
-		strlcpy(drvinfo->fw_version, "N/A",
+		strscpy(drvinfo->fw_version, "N/A",
 			sizeof(drvinfo->fw_version));
 	else
 		snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
 			 "%u.%u", version_major, version_minor);
 
-	strlcpy(drvinfo->bus_info, dev_name(netdev->dev.parent->parent),
+	strscpy(drvinfo->bus_info, dev_name(netdev->dev.parent->parent),
 		sizeof(drvinfo->bus_info));
 }
 
-- 
2.29.2


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

* [PATCH 04/13] staging: most: Switch from strlcpy to strscpy
  2021-01-31 17:28 [PATCH 00/13] Convert all users of strlcpy to strscpy Kumar Kartikeya Dwivedi
                   ` (2 preceding siblings ...)
  2021-01-31 17:28 ` [PATCH 03/13] staging: fsl-dpaa2: " Kumar Kartikeya Dwivedi
@ 2021-01-31 17:28 ` Kumar Kartikeya Dwivedi
  2021-01-31 17:28 ` [PATCH 05/13] staging: nvec: " Kumar Kartikeya Dwivedi
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-01-31 17:28 UTC (permalink / raw)
  To: devel, gregkh, linux-kernel
  Cc: Kumar Kartikeya Dwivedi, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Stephen Rothwell, Andrew Morton, Mike Rapoport, Thomas Gleixner,
	Robert Richter, Florian Fainelli, Al Viro, greybus-dev, ac100,
	linux-tegra, linux-fbdev

strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
and there is no functional difference when the caller expects truncation
(when not checking the return value). strscpy is relatively better as it
also avoids scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 drivers/staging/most/sound/sound.c | 2 +-
 drivers/staging/most/video/video.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c
index 3a1a59058..c4287994b 100644
--- a/drivers/staging/most/sound/sound.c
+++ b/drivers/staging/most/sound/sound.c
@@ -525,7 +525,7 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id,
 		pr_err("Incompatible channel type\n");
 		return -EINVAL;
 	}
-	strlcpy(arg_list_cpy, arg_list, STRING_SIZE);
+	strscpy(arg_list_cpy, arg_list, STRING_SIZE);
 	ret = split_arg_list(arg_list_cpy, &ch_num, &sample_res);
 	if (ret < 0)
 		return ret;
diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c
index 829df899b..90933d78c 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -245,8 +245,8 @@ static int vidioc_querycap(struct file *file, void *priv,
 	struct comp_fh *fh = priv;
 	struct most_video_dev *mdev = fh->mdev;
 
-	strlcpy(cap->driver, "v4l2_component", sizeof(cap->driver));
-	strlcpy(cap->card, "MOST", sizeof(cap->card));
+	strscpy(cap->driver, "v4l2_component", sizeof(cap->driver));
+	strscpy(cap->card, "MOST", sizeof(cap->card));
 	snprintf(cap->bus_info, sizeof(cap->bus_info),
 		 "%s", mdev->iface->description);
 	return 0;
@@ -483,7 +483,7 @@ static int comp_probe_channel(struct most_interface *iface, int channel_idx,
 	mdev->v4l2_dev.release = comp_v4l2_dev_release;
 
 	/* Create the v4l2_device */
-	strlcpy(mdev->v4l2_dev.name, name, sizeof(mdev->v4l2_dev.name));
+	strscpy(mdev->v4l2_dev.name, name, sizeof(mdev->v4l2_dev.name));
 	ret = v4l2_device_register(NULL, &mdev->v4l2_dev);
 	if (ret) {
 		pr_err("v4l2_device_register() failed\n");
-- 
2.29.2


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

* [PATCH 05/13] staging: nvec: Switch from strlcpy to strscpy
  2021-01-31 17:28 [PATCH 00/13] Convert all users of strlcpy to strscpy Kumar Kartikeya Dwivedi
                   ` (3 preceding siblings ...)
  2021-01-31 17:28 ` [PATCH 04/13] staging: most: " Kumar Kartikeya Dwivedi
@ 2021-01-31 17:28 ` Kumar Kartikeya Dwivedi
  2021-01-31 17:28 ` [PATCH 06/13] staging: octeon: " Kumar Kartikeya Dwivedi
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-01-31 17:28 UTC (permalink / raw)
  To: devel, gregkh, linux-kernel
  Cc: Kumar Kartikeya Dwivedi, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Stephen Rothwell, Andrew Morton, Thomas Gleixner, William Cohen,
	Mike Rapoport, Florian Fainelli, Robert Richter, Al Viro,
	greybus-dev, ac100, linux-tegra, linux-fbdev

strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
and there is no functional difference when the caller expects truncation
(when not checking the return value). strscpy is relatively better as it
also avoids scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 drivers/staging/nvec/nvec_ps2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c
index 45db29262..157009015 100644
--- a/drivers/staging/nvec/nvec_ps2.c
+++ b/drivers/staging/nvec/nvec_ps2.c
@@ -112,8 +112,8 @@ static int nvec_mouse_probe(struct platform_device *pdev)
 	ser_dev->start = ps2_startstreaming;
 	ser_dev->stop = ps2_stopstreaming;
 
-	strlcpy(ser_dev->name, "nvec mouse", sizeof(ser_dev->name));
-	strlcpy(ser_dev->phys, "nvec", sizeof(ser_dev->phys));
+	strscpy(ser_dev->name, "nvec mouse", sizeof(ser_dev->name));
+	strscpy(ser_dev->phys, "nvec", sizeof(ser_dev->phys));
 
 	ps2_dev.ser_dev = ser_dev;
 	ps2_dev.notifier.notifier_call = nvec_ps2_notifier;
-- 
2.29.2


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

* [PATCH 06/13] staging: octeon: Switch from strlcpy to strscpy
  2021-01-31 17:28 [PATCH 00/13] Convert all users of strlcpy to strscpy Kumar Kartikeya Dwivedi
                   ` (4 preceding siblings ...)
  2021-01-31 17:28 ` [PATCH 05/13] staging: nvec: " Kumar Kartikeya Dwivedi
@ 2021-01-31 17:28 ` Kumar Kartikeya Dwivedi
  2021-02-16 14:36   ` Robert Richter
  2021-01-31 17:28 ` [PATCH 07/13] staging: olpc_dcon: " Kumar Kartikeya Dwivedi
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 18+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-01-31 17:28 UTC (permalink / raw)
  To: devel, gregkh, linux-kernel
  Cc: Kumar Kartikeya Dwivedi, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Stephen Rothwell, Andrew Morton, William Cohen, Florian Fainelli,
	Al Viro, Mike Rapoport, Robert Richter, Thomas Gleixner,
	greybus-dev, ac100, linux-tegra, linux-fbdev

strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
and there is no functional difference when the caller expects truncation
(when not checking the return value). strscpy is relatively better as it
also avoids scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 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 0bf545849..1bb91a904 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	[flat|nested] 18+ messages in thread

* [PATCH 07/13] staging: olpc_dcon: Switch from strlcpy to strscpy
  2021-01-31 17:28 [PATCH 00/13] Convert all users of strlcpy to strscpy Kumar Kartikeya Dwivedi
                   ` (5 preceding siblings ...)
  2021-01-31 17:28 ` [PATCH 06/13] staging: octeon: " Kumar Kartikeya Dwivedi
@ 2021-01-31 17:28 ` Kumar Kartikeya Dwivedi
  2021-01-31 17:28 ` [PATCH 08/13] staging: rtl8188eu: " Kumar Kartikeya Dwivedi
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-01-31 17:28 UTC (permalink / raw)
  To: devel, gregkh, linux-kernel
  Cc: Kumar Kartikeya Dwivedi, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Stephen Rothwell, Andrew Morton, William Cohen, Mike Rapoport,
	Florian Fainelli, Robert Richter, Thomas Gleixner, Al Viro,
	greybus-dev, ac100, linux-tegra, linux-fbdev

strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
and there is no functional difference when the caller expects truncation
(when not checking the return value). strscpy is relatively better as it
also avoids scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 drivers/staging/olpc_dcon/olpc_dcon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c
index e7281212d..6d8e9a481 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -576,7 +576,7 @@ static struct notifier_block dcon_panic_nb = {
 
 static int dcon_detect(struct i2c_client *client, struct i2c_board_info *info)
 {
-	strlcpy(info->type, "olpc_dcon", I2C_NAME_SIZE);
+	strscpy(info->type, "olpc_dcon", I2C_NAME_SIZE);
 
 	return 0;
 }
-- 
2.29.2


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

* [PATCH 08/13] staging: rtl8188eu: Switch from strlcpy to strscpy
  2021-01-31 17:28 [PATCH 00/13] Convert all users of strlcpy to strscpy Kumar Kartikeya Dwivedi
                   ` (6 preceding siblings ...)
  2021-01-31 17:28 ` [PATCH 07/13] staging: olpc_dcon: " Kumar Kartikeya Dwivedi
@ 2021-01-31 17:28 ` Kumar Kartikeya Dwivedi
  2021-01-31 17:28 ` [PATCH 09/13] staging: rtl8192e: " Kumar Kartikeya Dwivedi
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-01-31 17:28 UTC (permalink / raw)
  To: devel, gregkh, linux-kernel
  Cc: Kumar Kartikeya Dwivedi, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Stephen Rothwell, Andrew Morton, Thomas Gleixner, Mike Rapoport,
	Al Viro, Florian Fainelli, Robert Richter, William Cohen,
	greybus-dev, ac100, linux-tegra, linux-fbdev

strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
and there is no functional difference when the caller expects truncation
(when not checking the return value). strscpy is relatively better as it
also avoids scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index 6f42f13a7..bf22f130d 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -1865,7 +1865,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev,
 		goto exit;
 	}
 
-	strlcpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN);
+	strscpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN);
 
 	if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
 		param->u.crypt.set_tx = 1;
-- 
2.29.2


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

* [PATCH 09/13] staging: rtl8192e: Switch from strlcpy to strscpy
  2021-01-31 17:28 [PATCH 00/13] Convert all users of strlcpy to strscpy Kumar Kartikeya Dwivedi
                   ` (7 preceding siblings ...)
  2021-01-31 17:28 ` [PATCH 08/13] staging: rtl8188eu: " Kumar Kartikeya Dwivedi
@ 2021-01-31 17:28 ` Kumar Kartikeya Dwivedi
  2021-01-31 17:28 ` [PATCH 10/13] staging: rtl8192u: " Kumar Kartikeya Dwivedi
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-01-31 17:28 UTC (permalink / raw)
  To: devel, gregkh, linux-kernel
  Cc: Kumar Kartikeya Dwivedi, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Stephen Rothwell, Andrew Morton, Al Viro, Florian Fainelli,
	Mike Rapoport, Thomas Gleixner, Robert Richter, William Cohen,
	greybus-dev, ac100, linux-tegra, linux-fbdev

strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
and there is no functional difference when the caller expects truncation
(when not checking the return value). strscpy is relatively better as it
also avoids scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 drivers/staging/rtl8192e/rtl8192e/rtl_ethtool.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_ethtool.c b/drivers/staging/rtl8192e/rtl8192e/rtl_ethtool.c
index 6ae7a67e7..f4f7b74c8 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_ethtool.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_ethtool.c
@@ -18,9 +18,9 @@ static void _rtl92e_ethtool_get_drvinfo(struct net_device *dev,
 {
 	struct r8192_priv *priv = rtllib_priv(dev);
 
-	strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
-	strlcpy(info->version, DRV_VERSION, sizeof(info->version));
-	strlcpy(info->bus_info, pci_name(priv->pdev), sizeof(info->bus_info));
+	strscpy(info->driver, DRV_NAME, sizeof(info->driver));
+	strscpy(info->version, DRV_VERSION, sizeof(info->version));
+	strscpy(info->bus_info, pci_name(priv->pdev), sizeof(info->bus_info));
 }
 
 static u32 _rtl92e_ethtool_get_link(struct net_device *dev)
-- 
2.29.2


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

* [PATCH 10/13] staging: rtl8192u: Switch from strlcpy to strscpy
  2021-01-31 17:28 [PATCH 00/13] Convert all users of strlcpy to strscpy Kumar Kartikeya Dwivedi
                   ` (8 preceding siblings ...)
  2021-01-31 17:28 ` [PATCH 09/13] staging: rtl8192e: " Kumar Kartikeya Dwivedi
@ 2021-01-31 17:28 ` Kumar Kartikeya Dwivedi
  2021-01-31 17:28 ` [PATCH 11/13] staging: rtl8712: " Kumar Kartikeya Dwivedi
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-01-31 17:28 UTC (permalink / raw)
  To: devel, gregkh, linux-kernel
  Cc: Kumar Kartikeya Dwivedi, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Stephen Rothwell, Andrew Morton, Al Viro, William Cohen,
	Florian Fainelli, Mike Rapoport, Robert Richter, Thomas Gleixner,
	greybus-dev, ac100, linux-tegra, linux-fbdev

strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
and there is no functional difference when the caller expects truncation
(when not checking the return value). strscpy is relatively better as it
also avoids scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c
index f434a26cd..afa92ddfa 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c
@@ -484,7 +484,7 @@ int ieee80211_wx_get_name(struct ieee80211_device *ieee,
 			     struct iw_request_info *info,
 			     union iwreq_data *wrqu, char *extra)
 {
-	strlcpy(wrqu->name, "802.11", IFNAMSIZ);
+	strscpy(wrqu->name, "802.11", IFNAMSIZ);
 	if (ieee->modulation & IEEE80211_CCK_MODULATION) {
 		strlcat(wrqu->name, "b", IFNAMSIZ);
 		if (ieee->modulation & IEEE80211_OFDM_MODULATION)
-- 
2.29.2


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

* [PATCH 11/13] staging: rtl8712: Switch from strlcpy to strscpy
  2021-01-31 17:28 [PATCH 00/13] Convert all users of strlcpy to strscpy Kumar Kartikeya Dwivedi
                   ` (9 preceding siblings ...)
  2021-01-31 17:28 ` [PATCH 10/13] staging: rtl8192u: " Kumar Kartikeya Dwivedi
@ 2021-01-31 17:28 ` Kumar Kartikeya Dwivedi
  2021-01-31 17:28 ` [PATCH 12/13] staging: sm750fb: " Kumar Kartikeya Dwivedi
  2021-01-31 17:28 ` [PATCH 13/13] staging: wimax: " Kumar Kartikeya Dwivedi
  12 siblings, 0 replies; 18+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-01-31 17:28 UTC (permalink / raw)
  To: devel, gregkh, linux-kernel
  Cc: Kumar Kartikeya Dwivedi, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Stephen Rothwell, Andrew Morton, Robert Richter, Thomas Gleixner,
	William Cohen, Florian Fainelli, Mike Rapoport, Al Viro,
	greybus-dev, ac100, linux-tegra, linux-fbdev

strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
and there is no functional difference when the caller expects truncation
(when not checking the return value). strscpy is relatively better as it
also avoids scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index cbaa7a489..81de5a9e6 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1784,7 +1784,7 @@ static int r871x_wx_set_enc_ext(struct net_device *dev,
 		return -ENOMEM;
 	param->cmd = IEEE_CMD_SET_ENCRYPTION;
 	eth_broadcast_addr(param->sta_addr);
-	strlcpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN);
+	strscpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN);
 	if (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
 		param->u.crypt.set_tx = 0;
 	if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
-- 
2.29.2


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

* [PATCH 12/13] staging: sm750fb: Switch from strlcpy to strscpy
  2021-01-31 17:28 [PATCH 00/13] Convert all users of strlcpy to strscpy Kumar Kartikeya Dwivedi
                   ` (10 preceding siblings ...)
  2021-01-31 17:28 ` [PATCH 11/13] staging: rtl8712: " Kumar Kartikeya Dwivedi
@ 2021-01-31 17:28 ` Kumar Kartikeya Dwivedi
  2021-01-31 17:28 ` [PATCH 13/13] staging: wimax: " Kumar Kartikeya Dwivedi
  12 siblings, 0 replies; 18+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-01-31 17:28 UTC (permalink / raw)
  To: devel, gregkh, linux-kernel
  Cc: Kumar Kartikeya Dwivedi, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Stephen Rothwell, Andrew Morton, Robert Richter, William Cohen,
	Florian Fainelli, Mike Rapoport, Thomas Gleixner, Al Viro,
	greybus-dev, ac100, linux-tegra, linux-fbdev

strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
and there is no functional difference when the caller expects truncation
(when not checking the return value). strscpy is relatively better as it
also avoids scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 drivers/staging/sm750fb/sm750.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 029f0d09e..c237a8f8e 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -814,7 +814,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
 	fix->ywrapstep = crtc->ywrapstep;
 	fix->accel = FB_ACCEL_SMI;
 
-	strlcpy(fix->id, fixId[index], sizeof(fix->id));
+	strscpy(fix->id, fixId[index], sizeof(fix->id));
 
 	fix->smem_start = crtc->oScreen + sm750_dev->vidmem_start;
 	pr_info("fix->smem_start = %lx\n", fix->smem_start);
-- 
2.29.2


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

* [PATCH 13/13] staging: wimax: Switch from strlcpy to strscpy
  2021-01-31 17:28 [PATCH 00/13] Convert all users of strlcpy to strscpy Kumar Kartikeya Dwivedi
                   ` (11 preceding siblings ...)
  2021-01-31 17:28 ` [PATCH 12/13] staging: sm750fb: " Kumar Kartikeya Dwivedi
@ 2021-01-31 17:28 ` Kumar Kartikeya Dwivedi
  12 siblings, 0 replies; 18+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-01-31 17:28 UTC (permalink / raw)
  To: devel, gregkh, linux-kernel
  Cc: Kumar Kartikeya Dwivedi, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Andrew Morton, Stephen Rothwell, Thomas Gleixner, Mike Rapoport,
	Florian Fainelli, William Cohen, Robert Richter, Al Viro,
	greybus-dev, ac100, linux-tegra, linux-fbdev

strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
and there is no functional difference when the caller expects truncation
(when not checking the return value). strscpy is relatively better as it
also avoids scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 drivers/staging/wimax/i2400m/netdev.c | 6 +++---
 drivers/staging/wimax/i2400m/usb.c    | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wimax/i2400m/netdev.c b/drivers/staging/wimax/i2400m/netdev.c
index 8339d600e..cd06eaf75 100644
--- a/drivers/staging/wimax/i2400m/netdev.c
+++ b/drivers/staging/wimax/i2400m/netdev.c
@@ -561,11 +561,11 @@ static void i2400m_get_drvinfo(struct net_device *net_dev,
 {
 	struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
 
-	strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
-	strlcpy(info->fw_version, i2400m->fw_name ? : "",
+	strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
+	strscpy(info->fw_version, i2400m->fw_name ? : "",
 		sizeof(info->fw_version));
 	if (net_dev->dev.parent)
-		strlcpy(info->bus_info, dev_name(net_dev->dev.parent),
+		strscpy(info->bus_info, dev_name(net_dev->dev.parent),
 			sizeof(info->bus_info));
 }
 
diff --git a/drivers/staging/wimax/i2400m/usb.c b/drivers/staging/wimax/i2400m/usb.c
index f250d03ce..481b1ccde 100644
--- a/drivers/staging/wimax/i2400m/usb.c
+++ b/drivers/staging/wimax/i2400m/usb.c
@@ -333,8 +333,8 @@ static void i2400mu_get_drvinfo(struct net_device *net_dev,
 	struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
 	struct usb_device *udev = i2400mu->usb_dev;
 
-	strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
-	strlcpy(info->fw_version, i2400m->fw_name ? : "",
+	strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
+	strscpy(info->fw_version, i2400m->fw_name ? : "",
 		sizeof(info->fw_version));
 	usb_make_path(udev, info->bus_info, sizeof(info->bus_info));
 }
-- 
2.29.2


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

* Re: [PATCH 06/13] staging: octeon: Switch from strlcpy to strscpy
  2021-01-31 17:28 ` [PATCH 06/13] staging: octeon: " Kumar Kartikeya Dwivedi
@ 2021-02-16 14:36   ` Robert Richter
  0 siblings, 0 replies; 18+ messages in thread
From: Robert Richter @ 2021-02-16 14:36 UTC (permalink / raw)
  To: Kumar Kartikeya Dwivedi
  Cc: devel, gregkh, linux-kernel, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Stephen Rothwell, Andrew Morton, William Cohen, Florian Fainelli,
	Al Viro, Mike Rapoport, Thomas Gleixner, greybus-dev, ac100,
	linux-tegra, linux-fbdev

On 31.01.21 22:58:27, Kumar Kartikeya Dwivedi wrote:
> strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
> and there is no functional difference when the caller expects truncation
> (when not checking the return value). strscpy is relatively better as it
> also avoids scanning the whole source string.
> 
> This silences the related checkpatch warnings from:
> 5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")
> 
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> ---
>  drivers/staging/octeon/ethernet-mdio.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Robert Richter <rric@kernel.org>

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

* Re: [PATCH 02/13] staging: greybus: Switch from strlcpy to strscpy
  2021-01-31 17:28 ` [PATCH 02/13] staging: greybus: " Kumar Kartikeya Dwivedi
@ 2021-02-16 14:54   ` Alex Elder
  2021-02-16 15:48     ` Kumar Kartikeya Dwivedi
  0 siblings, 1 reply; 18+ messages in thread
From: Alex Elder @ 2021-02-16 14:54 UTC (permalink / raw)
  To: Kumar Kartikeya Dwivedi, devel, gregkh, linux-kernel
  Cc: Ian Abbott, H Hartley Sweeten, Ioana Radulescu, Ioana Ciornei,
	Johan Hovold, Alex Elder, Vaibhav Agarwal, Mark Greer,
	Rui Miguel Silva, Viresh Kumar, Marc Dietrich, Jens Frederich,
	Daniel Drake, Jon Nettleton, Larry Finger, Florian Schilhabel,
	Sudip Mukherjee, Teddy Wang, Stephen Rothwell, Andrew Morton,
	Florian Fainelli, Al Viro, William Cohen, Mike Rapoport,
	Thomas Gleixner, Robert Richter, greybus-dev, ac100, linux-tegra,
	linux-fbdev

On 1/31/21 11:28 AM, Kumar Kartikeya Dwivedi wrote:
> strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
> and there is no functional difference when the caller expects truncation
> (when not checking the return value). strscpy is relatively better as it
> also avoids scanning the whole source string.
> 
> This silences the related checkpatch warnings from:
> 5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")
> 
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>

This is a good change.  But while you're at it, I would
appreciate if you would convert a few spots to use
sizeof(dest) rather than a fixed constant.  I will
point them out below.

If this is the *only* request for a change on your
series, please tell me that and I can sign off on
this without you implementing my suggestion.  But
if you post a version 2, please do what I describe.

Thanks.

					-Alex

> ---
>   drivers/staging/greybus/audio_helper.c   | 2 +-
>   drivers/staging/greybus/audio_module.c   | 2 +-
>   drivers/staging/greybus/audio_topology.c | 6 +++---
>   drivers/staging/greybus/power_supply.c   | 2 +-
>   drivers/staging/greybus/spilib.c         | 4 ++--
>   5 files changed, 8 insertions(+), 8 deletions(-)

. . .


> diff --git a/drivers/staging/greybus/audio_module.c b/drivers/staging/greybus/audio_module.c
> index a243d60f0..0f9fdc077 100644
> --- a/drivers/staging/greybus/audio_module.c
> +++ b/drivers/staging/greybus/audio_module.c
> @@ -342,7 +342,7 @@ static int gb_audio_probe(struct gb_bundle *bundle,
>   	/* inform above layer for uevent */
>   	dev_dbg(dev, "Inform set_event:%d to above layer\n", 1);
>   	/* prepare for the audio manager */
> -	strlcpy(desc.name, gbmodule->name, GB_AUDIO_MANAGER_MODULE_NAME_LEN);
> +	strscpy(desc.name, gbmodule->name, GB_AUDIO_MANAGER_MODULE_NAME_LEN);

Please use this here instead:

	strscpy(desc.name, gbmodule->name, sizeof(desc.name));

>   	desc.vid = 2; /* todo */
>   	desc.pid = 3; /* todo */
>   	desc.intf_id = gbmodule->dev_id;
> diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c
> index 662e3e8b4..e816e4db5 100644
> --- a/drivers/staging/greybus/audio_topology.c
> +++ b/drivers/staging/greybus/audio_topology.c
> @@ -200,7 +200,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol,
>   			return -EINVAL;
>   		name = gbaudio_map_controlid(module, data->ctl_id,
>   					     uinfo->value.enumerated.item);
> -		strlcpy(uinfo->value.enumerated.name, name, NAME_SIZE);
> +		strscpy(uinfo->value.enumerated.name, name, NAME_SIZE);

Please use this here instead:

		strscpy(uinfo->value.enumerated.name, name,
			sizeof(uinfo->valiue.enumerated.name));

(I know NAME_SIZE is used throughout this file, and
could also be converted in this way, but we can save
that for another patch.)

>   		break;
>   	default:
>   		dev_err(comp->dev, "Invalid type: %d for %s:kcontrol\n",
> @@ -1047,7 +1047,7 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module,
>   	}
>   
>   	/* Prefix dev_id to widget control_name */
> -	strlcpy(temp_name, w->name, NAME_SIZE);
> +	strscpy(temp_name, w->name, NAME_SIZE);

Please use this here instead:

	strscpy(temp_name, w->name, sizeof(temp_name));

>   	snprintf(w->name, NAME_SIZE, "GB %d %s", module->dev_id, temp_name);
>   
>   	switch (w->type) {
> @@ -1169,7 +1169,7 @@ static int gbaudio_tplg_process_kcontrols(struct gbaudio_module_info *module,
>   		}
>   		control->id = curr->id;
>   		/* Prefix dev_id to widget_name */
> -		strlcpy(temp_name, curr->name, NAME_SIZE);
> +		strscpy(temp_name, curr->name, NAME_SIZE);


Please use this here instead:

		strscpy(temp_name, curr->name, sizeof(temp_name));

>   		snprintf(curr->name, NAME_SIZE, "GB %d %s", module->dev_id,
>   			 temp_name);
>   		control->name = curr->name;

. . .

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

* Re: [PATCH 02/13] staging: greybus: Switch from strlcpy to strscpy
  2021-02-16 14:54   ` Alex Elder
@ 2021-02-16 15:48     ` Kumar Kartikeya Dwivedi
  2021-02-16 15:49       ` Alex Elder
  0 siblings, 1 reply; 18+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2021-02-16 15:48 UTC (permalink / raw)
  To: Alex Elder
  Cc: devel, gregkh, linux-kernel, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Stephen Rothwell, Andrew Morton, Florian Fainelli, Al Viro,
	William Cohen, Mike Rapoport, Thomas Gleixner, Robert Richter,
	greybus-dev, ac100, linux-tegra, linux-fbdev

On Tue, Feb 16, 2021 at 08:24:59PM IST, Alex Elder wrote:
> This is a good change.  But while you're at it, I would
> appreciate if you would convert a few spots to use
> sizeof(dest) rather than a fixed constant.  I will
> point them out below.
> 
> If this is the *only* request for a change on your
> series, please tell me that and I can sign off on

So far, this has been the only request.

> this without you implementing my suggestion.  But
> if you post a version 2, please do what I describe.
> 

I will incorporate these if I end up sending a v2.

Alternatively, would a separate patch with your suggestions applied on top of
this be acceptable, if I don't?

-- 
Kartikeya

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

* Re: [PATCH 02/13] staging: greybus: Switch from strlcpy to strscpy
  2021-02-16 15:48     ` Kumar Kartikeya Dwivedi
@ 2021-02-16 15:49       ` Alex Elder
  0 siblings, 0 replies; 18+ messages in thread
From: Alex Elder @ 2021-02-16 15:49 UTC (permalink / raw)
  To: Kumar Kartikeya Dwivedi
  Cc: devel, gregkh, linux-kernel, Ian Abbott, H Hartley Sweeten,
	Ioana Radulescu, Ioana Ciornei, Johan Hovold, Alex Elder,
	Vaibhav Agarwal, Mark Greer, Rui Miguel Silva, Viresh Kumar,
	Marc Dietrich, Jens Frederich, Daniel Drake, Jon Nettleton,
	Larry Finger, Florian Schilhabel, Sudip Mukherjee, Teddy Wang,
	Stephen Rothwell, Andrew Morton, Florian Fainelli, Al Viro,
	William Cohen, Mike Rapoport, Thomas Gleixner, Robert Richter,
	greybus-dev, ac100, linux-tegra, linux-fbdev

On 2/16/21 9:48 AM, Kumar Kartikeya Dwivedi wrote:
> On Tue, Feb 16, 2021 at 08:24:59PM IST, Alex Elder wrote:
>> This is a good change.  But while you're at it, I would
>> appreciate if you would convert a few spots to use
>> sizeof(dest) rather than a fixed constant.  I will
>> point them out below.
>>
>> If this is the *only* request for a change on your
>> series, please tell me that and I can sign off on
> 
> So far, this has been the only request.
> 
>> this without you implementing my suggestion.  But
>> if you post a version 2, please do what I describe.
>>
> 
> I will incorporate these if I end up sending a v2.
> 
> Alternatively, would a separate patch with your suggestions applied on top of
> this be acceptable, if I don't?

Yes.  Assuming you do that, for this patch (as-is):

Reviewed-by: Alex Elder <elder@linaro.org>


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

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

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-31 17:28 [PATCH 00/13] Convert all users of strlcpy to strscpy Kumar Kartikeya Dwivedi
2021-01-31 17:28 ` [PATCH 01/13] staging: comedi: Switch from " Kumar Kartikeya Dwivedi
2021-01-31 17:28 ` [PATCH 02/13] staging: greybus: " Kumar Kartikeya Dwivedi
2021-02-16 14:54   ` Alex Elder
2021-02-16 15:48     ` Kumar Kartikeya Dwivedi
2021-02-16 15:49       ` Alex Elder
2021-01-31 17:28 ` [PATCH 03/13] staging: fsl-dpaa2: " Kumar Kartikeya Dwivedi
2021-01-31 17:28 ` [PATCH 04/13] staging: most: " Kumar Kartikeya Dwivedi
2021-01-31 17:28 ` [PATCH 05/13] staging: nvec: " Kumar Kartikeya Dwivedi
2021-01-31 17:28 ` [PATCH 06/13] staging: octeon: " Kumar Kartikeya Dwivedi
2021-02-16 14:36   ` Robert Richter
2021-01-31 17:28 ` [PATCH 07/13] staging: olpc_dcon: " Kumar Kartikeya Dwivedi
2021-01-31 17:28 ` [PATCH 08/13] staging: rtl8188eu: " Kumar Kartikeya Dwivedi
2021-01-31 17:28 ` [PATCH 09/13] staging: rtl8192e: " Kumar Kartikeya Dwivedi
2021-01-31 17:28 ` [PATCH 10/13] staging: rtl8192u: " Kumar Kartikeya Dwivedi
2021-01-31 17:28 ` [PATCH 11/13] staging: rtl8712: " Kumar Kartikeya Dwivedi
2021-01-31 17:28 ` [PATCH 12/13] staging: sm750fb: " Kumar Kartikeya Dwivedi
2021-01-31 17:28 ` [PATCH 13/13] staging: wimax: " Kumar Kartikeya Dwivedi

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).