staging: most: Switch from strlcpy to strscpy
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Sun, 31 Jan 2021 17:28:25 +0000 (22:58 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Feb 2021 16:16:06 +0000 (17:16 +0100)
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>
Link: https://lore.kernel.org/r/20210131172838.146706-5-memxor@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/most/sound/sound.c
drivers/staging/most/video/video.c

index 52f87a3ef72947abfe8cd86470615b1ff32b6898..c87f6a037874ee512b119da5bb155e73b088a25c 100644 (file)
@@ -527,7 +527,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;
index 829df899b9930384c13631a4f34be40c1de99e1a..90933d78c332523307373a24b01f74df13ed0328 100644 (file)
@@ -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");