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
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(-)
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(-)
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(-)
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(-)
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(-)
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(-)
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(-)
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(-)
@@ -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;
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(-)
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(-)
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(-)
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(-)
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(-)
From: Robert Richter <rric@kernel.org> Date: 2021-02-16 14:39:29
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(-)
From: Alex Elder <hidden> Date: 2021-02-16 14:56:04
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
@@ -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));
quoted hunk
desc.vid = 2; /* todo */
desc.pid = 3; /* todo */
desc.intf_id = gbmodule->dev_id;
@@ -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.)
quoted hunk
break;
default:
dev_err(comp->dev, "Invalid type: %d for %s:kcontrol\n",
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
From: Alex Elder <hidden> Date: 2021-02-16 15:51:44
On 2/16/21 9:48 AM, Kumar Kartikeya Dwivedi wrote:
On Tue, Feb 16, 2021 at 08:24:59PM IST, Alex Elder wrote:
quoted
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.
quoted
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 <redacted>