media: replace strncpy() by strscpy()
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 10 Sep 2018 12:19:16 +0000 (08:19 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Fri, 29 Mar 2019 14:26:13 +0000 (10:26 -0400)
The strncpy() function is being deprecated upstream. Replace
it by the safer strscpy().

While here, replace a few occurences of strlcpy() that were
recently added to also use strscpy().

Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
35 files changed:
drivers/media/dvb-frontends/as102_fe.c
drivers/media/dvb-frontends/dib7000p.c
drivers/media/dvb-frontends/dib8000.c
drivers/media/dvb-frontends/dib9000.c
drivers/media/dvb-frontends/dvb-pll.c
drivers/media/dvb-frontends/m88ds3103.c
drivers/media/pci/bt8xx/dst.c
drivers/media/pci/mantis/mantis_i2c.c
drivers/media/pci/saa7134/saa7134-go7007.c
drivers/media/platform/am437x/am437x-vpfe.c
drivers/media/platform/davinci/vpfe_capture.c
drivers/media/platform/davinci/vpif_capture.c
drivers/media/platform/davinci/vpif_display.c
drivers/media/platform/exynos4-is/fimc-capture.c
drivers/media/platform/exynos4-is/fimc-m2m.c
drivers/media/platform/imx-pxp.c
drivers/media/platform/mtk-vpu/mtk_vpu.c
drivers/media/platform/mx2_emmaprp.c
drivers/media/platform/s5p-g2d/g2d.c
drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c
drivers/media/platform/ti-vpe/vpe.c
drivers/media/platform/vicodec/vicodec-core.c
drivers/media/platform/vim2m.c
drivers/media/platform/vivid/vivid-core.c
drivers/media/radio/si4713/si4713.c
drivers/media/usb/go7007/go7007-usb.c
drivers/media/usb/go7007/go7007-v4l2.c
drivers/media/usb/hdpvr/hdpvr-video.c
drivers/media/usb/pulse8-cec/pulse8-cec.c
drivers/media/usb/pvrusb2/pvrusb2-hdw.c
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
drivers/staging/media/bcm2048/radio-bcm2048.c
drivers/staging/media/imx/imx-ic-common.c
drivers/staging/media/imx/imx-media-vdic.c
drivers/staging/media/zoran/zoran_driver.c

index f59a102b0a648b9cf746a345834ed17a4bac9a32..9ba8f39fe31015977aa64f96084fb7863d897f6c 100644 (file)
@@ -467,7 +467,7 @@ struct dvb_frontend *as102_attach(const char *name,
 
        /* init frontend callback ops */
        memcpy(&fe->ops, &as102_fe_ops, sizeof(struct dvb_frontend_ops));
-       strncpy(fe->ops.info.name, name, sizeof(fe->ops.info.name));
+       strscpy(fe->ops.info.name, name, sizeof(fe->ops.info.name));
 
        return fe;
 
index f8040f6def628b33a8fbe8b5664f6cfdfa121625..d869029ca87d140f68998c40668406309182b56f 100644 (file)
@@ -2774,7 +2774,8 @@ static struct dvb_frontend *dib7000p_init(struct i2c_adapter *i2c_adap, u8 i2c_a
        dibx000_init_i2c_master(&st->i2c_master, DIB7000P, st->i2c_adap, st->i2c_addr);
 
        /* init 7090 tuner adapter */
-       strncpy(st->dib7090_tuner_adap.name, "DiB7090 tuner interface", sizeof(st->dib7090_tuner_adap.name));
+       strscpy(st->dib7090_tuner_adap.name, "DiB7090 tuner interface",
+               sizeof(st->dib7090_tuner_adap.name));
        st->dib7090_tuner_adap.algo = &dib7090_tuner_xfer_algo;
        st->dib7090_tuner_adap.algo_data = NULL;
        st->dib7090_tuner_adap.dev.parent = st->i2c_adap->dev.parent;
index 85c429cce23ee382b3b0a0d9edd86188b8d5ece9..564669338dc695089fa147050df83b82c4ea2361 100644 (file)
@@ -4458,8 +4458,8 @@ static struct dvb_frontend *dib8000_init(struct i2c_adapter *i2c_adap, u8 i2c_ad
        dibx000_init_i2c_master(&state->i2c_master, DIB8000, state->i2c.adap, state->i2c.addr);
 
        /* init 8096p tuner adapter */
-       strncpy(state->dib8096p_tuner_adap.name, "DiB8096P tuner interface",
-                       sizeof(state->dib8096p_tuner_adap.name));
+       strscpy(state->dib8096p_tuner_adap.name, "DiB8096P tuner interface",
+               sizeof(state->dib8096p_tuner_adap.name));
        state->dib8096p_tuner_adap.algo = &dib8096p_tuner_xfer_algo;
        state->dib8096p_tuner_adap.algo_data = NULL;
        state->dib8096p_tuner_adap.dev.parent = state->i2c.adap->dev.parent;
index 1875da07c150c71a15039ca95d573e5ce641c129..e7838926e6bc9fd723b2e6b8cebd49aaa6f3c09e 100644 (file)
@@ -2521,7 +2521,8 @@ struct dvb_frontend *dib9000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, c
        dibx000_init_i2c_master(&st->i2c_master, DIB7000MC, st->i2c.i2c_adap, st->i2c.i2c_addr);
 
        st->tuner_adap.dev.parent = i2c_adap->dev.parent;
-       strncpy(st->tuner_adap.name, "DIB9000_FW TUNER ACCESS", sizeof(st->tuner_adap.name));
+       strscpy(st->tuner_adap.name, "DIB9000_FW TUNER ACCESS",
+               sizeof(st->tuner_adap.name));
        st->tuner_adap.algo = &dib9000_tuner_algo;
        st->tuner_adap.algo_data = NULL;
        i2c_set_adapdata(&st->tuner_adap, st);
@@ -2529,7 +2530,8 @@ struct dvb_frontend *dib9000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, c
                goto error;
 
        st->component_bus.dev.parent = i2c_adap->dev.parent;
-       strncpy(st->component_bus.name, "DIB9000_FW COMPONENT BUS ACCESS", sizeof(st->component_bus.name));
+       strscpy(st->component_bus.name, "DIB9000_FW COMPONENT BUS ACCESS",
+               sizeof(st->component_bus.name));
        st->component_bus.algo = &dib9000_component_bus_algo;
        st->component_bus.algo_data = NULL;
        st->component_bus_speed = 340;
index 29836c1a40e987985937f89dc7574ca6205a489e..da1b48a185151f14e453bedb43787c06d6104a85 100644 (file)
@@ -839,7 +839,7 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr,
        memcpy(&fe->ops.tuner_ops, &dvb_pll_tuner_ops,
               sizeof(struct dvb_tuner_ops));
 
-       strncpy(fe->ops.tuner_ops.info.name, desc->name,
+       strscpy(fe->ops.tuner_ops.info.name, desc->name,
                sizeof(fe->ops.tuner_ops.info.name));
 
        fe->ops.tuner_ops.info.frequency_min_hz = desc->min;
index 403f42806455e8cac828733e25154d715c87f230..b543e1c4c4f9fdaeb62070d1ecd2cc9d526e0272 100644 (file)
@@ -1469,7 +1469,7 @@ static int m88ds3103_probe(struct i2c_client *client,
        /* create dvb_frontend */
        memcpy(&dev->fe.ops, &m88ds3103_ops, sizeof(struct dvb_frontend_ops));
        if (dev->chip_id == M88RS6000_CHIP_ID)
-               strncpy(dev->fe.ops.info.name, "Montage Technology M88RS6000",
+               strscpy(dev->fe.ops.info.name, "Montage Technology M88RS6000",
                        sizeof(dev->fe.ops.info.name));
        if (!pdata->attach_in_use)
                dev->fe.ops.release = NULL;
index c94318c71a0c342af48a81d2cecb25f746765778..3315a6d67edf17de24cbe47797dbb69cffc40e70 100644 (file)
@@ -1100,7 +1100,8 @@ static int dst_get_device_id(struct dst_state *state)
                        /*      Card capabilities       */
                        state->dst_hw_cap = p_dst_type->dst_feature;
                        pr_err("Recognise [%s]\n", p_dst_type->device_id);
-                       strncpy(&state->fw_name[0], p_dst_type->device_id, 6);
+                       strscpy((char *)state->fw_name, p_dst_type->device_id,
+                               sizeof(state->fw_name));
                        /*      Multiple tuners         */
                        if (p_dst_type->tuner_type & TUNER_TYPE_MULTI) {
                                switch (use_dst_type) {
index 6528a2180119f691b95028d50cae77256241bf23..f8b503ef42bc6b1dab35a7cb52068c1075b00940 100644 (file)
@@ -225,7 +225,7 @@ int mantis_i2c_init(struct mantis_pci *mantis)
 
        init_waitqueue_head(&mantis->i2c_wq);
        mutex_init(&mantis->i2c_lock);
-       strncpy(i2c_adapter->name, "Mantis I2C", sizeof(i2c_adapter->name));
+       strscpy(i2c_adapter->name, "Mantis I2C", sizeof(i2c_adapter->name));
        i2c_set_adapdata(i2c_adapter, mantis);
 
        i2c_adapter->owner      = THIS_MODULE;
index 275c5e15181886f20218ca519bc8a6d32a8ca49b..626e130a97707fe65ad7aedcf571c78d6b54d396 100644 (file)
@@ -444,7 +444,7 @@ static int saa7134_go7007_init(struct saa7134_dev *dev)
        sd = &saa->sd;
        v4l2_subdev_init(sd, &saa7134_go7007_sd_ops);
        v4l2_set_subdevdata(sd, saa);
-       strncpy(sd->name, "saa7134-go7007", sizeof(sd->name));
+       strscpy(sd->name, "saa7134-go7007", sizeof(sd->name));
 
        /* Allocate a couple pages for receiving the compressed stream */
        saa->top = (u8 *)get_zeroed_page(GFP_KERNEL);
index 5c17624aaade9797c1adb0d809eab0582d549e0d..fe7b937eb5f2a418e860c2131e00e23f4ffa0489 100644 (file)
@@ -1540,7 +1540,7 @@ static int vpfe_enum_fmt(struct file *file, void  *priv,
        if (!fmt)
                return -EINVAL;
 
-       strncpy(f->description, fmt->name, sizeof(f->description) - 1);
+       strscpy(f->description, fmt->name, sizeof(f->description));
        f->pixelformat = fmt->fourcc;
        f->type = vpfe->fmt.type;
 
index 26dadbba930f00e099a036dc27e983d421a28037..1e3a138305442aa69eea875409b05981b91e6cd7 100644 (file)
@@ -1759,7 +1759,7 @@ static int vpfe_probe(struct platform_device *pdev)
 
        mutex_lock(&ccdc_lock);
 
-       strncpy(ccdc_cfg->name, vpfe_cfg->ccdc, 32);
+       strscpy(ccdc_cfg->name, vpfe_cfg->ccdc, sizeof(ccdc_cfg->name));
        /* Get VINT0 irq resource */
        res1 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
        if (!res1) {
index 6216b7ac6875f753f67afaef464232d78c2e6641..b5aacb0fb96be3c3126d54f378748080349c7bf8 100644 (file)
@@ -1254,7 +1254,8 @@ static int vpif_s_dv_timings(struct file *file, void *priv,
        } else {
                std_info->l5 = std_info->vsize - (bt->vfrontporch - 1);
        }
-       strncpy(std_info->name, "Custom timings BT656/1120", VPIF_MAX_NAME);
+       strscpy(std_info->name, "Custom timings BT656/1120",
+               sizeof(std_info->name));
        std_info->width = bt->width;
        std_info->height = bt->height;
        std_info->frm_fmt = bt->interlaced ? 0 : 1;
index f4b4f2a1dfc07616dc7cc7a467a723712a73aabf..a69897c68a50f9031d942861bf1c58821f6c1b90 100644 (file)
@@ -987,8 +987,8 @@ static int vpif_s_dv_timings(struct file *file, void *priv,
        } else {
                std_info->l5 = std_info->vsize - (bt->vfrontporch - 1);
        }
-       strncpy(std_info->name, "Custom timings BT656/1120",
-                       VPIF_MAX_NAME);
+       strscpy(std_info->name, "Custom timings BT656/1120",
+               sizeof(std_info->name));
        std_info->width = bt->width;
        std_info->height = bt->height;
        std_info->frm_fmt = bt->interlaced ? 0 : 1;
index 3e9fcf4f8a13d8d1ce5414e6b11e60f53130064f..de4af0357a3c562e39653fe6e26f5662a837a101 100644 (file)
@@ -742,7 +742,7 @@ static int fimc_cap_enum_fmt_mplane(struct file *file, void *priv,
                               f->index);
        if (!fmt)
                return -EINVAL;
-       strncpy(f->description, fmt->name, sizeof(f->description) - 1);
+       strscpy(f->description, fmt->name, sizeof(f->description));
        f->pixelformat = fmt->fourcc;
        if (fmt->fourcc == MEDIA_BUS_FMT_JPEG_1X8)
                f->flags |= V4L2_FMT_FLAG_COMPRESSED;
index 61c8177409cfdd9dda804c723cf7cb60ba564ad3..1bea1ce4091e4e9d2326b63059cfee85248128ae 100644 (file)
@@ -252,7 +252,7 @@ static int fimc_m2m_enum_fmt_mplane(struct file *file, void *priv,
        if (!fmt)
                return -EINVAL;
 
-       strncpy(f->description, fmt->name, sizeof(f->description) - 1);
+       strscpy(f->description, fmt->name, sizeof(f->description));
        f->pixelformat = fmt->fourcc;
        return 0;
 }
index 0bcfc5aa8f3dda5f57d42fc1bf323de45d3c9571..8e7ef23b9a7edd74dd4b954d2b63d9d3748fa6c3 100644 (file)
@@ -1025,8 +1025,8 @@ static irqreturn_t pxp_irq_handler(int irq, void *dev_id)
 static int pxp_querycap(struct file *file, void *priv,
                           struct v4l2_capability *cap)
 {
-       strlcpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver));
-       strlcpy(cap->card, MEM2MEM_NAME, sizeof(cap->card));
+       strscpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver));
+       strscpy(cap->card, MEM2MEM_NAME, sizeof(cap->card));
        snprintf(cap->bus_info, sizeof(cap->bus_info),
                        "platform:%s", MEM2MEM_NAME);
        return 0;
index b6602490a247c55429bea653785cca1c397cfec5..46c45f93c977a3228d76b431566802c983448107 100644 (file)
@@ -614,7 +614,7 @@ static void vpu_init_ipi_handler(void *data, unsigned int len, void *priv)
        struct vpu_run *run = (struct vpu_run *)data;
 
        vpu->run.signaled = run->signaled;
-       strncpy(vpu->run.fw_ver, run->fw_ver, VPU_FW_VER_LEN);
+       strscpy(vpu->run.fw_ver, run->fw_ver, sizeof(vpu->run.fw_ver));
        vpu->run.dec_capability = run->dec_capability;
        vpu->run.enc_capability = run->enc_capability;
        wake_up_interruptible(&vpu->run.wq);
index f60f499c596b0b974827a527f3b76e9945f4f14a..e100b30bb6f51e1a6f9f4c02c9f1cc36eb87e0a5 100644 (file)
@@ -385,8 +385,8 @@ static irqreturn_t emmaprp_irq(int irq_emma, void *data)
 static int vidioc_querycap(struct file *file, void *priv,
                           struct v4l2_capability *cap)
 {
-       strncpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver) - 1);
-       strncpy(cap->card, MEM2MEM_NAME, sizeof(cap->card) - 1);
+       strscpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver));
+       strscpy(cap->card, MEM2MEM_NAME, sizeof(cap->card));
        cap->device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING;
        cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
        return 0;
index 971c4716501027dd1f4468209daf32b40210927b..c8f394e1aff46ec2aef95a15adecfb9164951f7d 100644 (file)
@@ -297,8 +297,8 @@ static int g2d_release(struct file *file)
 static int vidioc_querycap(struct file *file, void *priv,
                                struct v4l2_capability *cap)
 {
-       strncpy(cap->driver, G2D_NAME, sizeof(cap->driver) - 1);
-       strncpy(cap->card, G2D_NAME, sizeof(cap->card) - 1);
+       strscpy(cap->driver, G2D_NAME, sizeof(cap->driver));
+       strscpy(cap->card, G2D_NAME, sizeof(cap->card));
        cap->bus_info[0] = 0;
        cap->device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING;
        cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
@@ -312,7 +312,7 @@ static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
                return -EINVAL;
        fmt = &formats[f->index];
        f->pixelformat = fmt->fourcc;
-       strncpy(f->description, fmt->name, sizeof(f->description) - 1);
+       strscpy(f->description, fmt->name, sizeof(f->description));
        return 0;
 }
 
index 1fd16861f11145a24a65264bf377dbb97333ce23..f0dfe68486d16e45b813452ce092a2e107631784 100644 (file)
@@ -412,7 +412,7 @@ static int vidioc_enum_input(struct file *file, void *fh,
        if (inp->index != 0)
                return -EINVAL;
 
-       strlcpy(inp->name, "camera", sizeof(inp->name));
+       strscpy(inp->name, "camera", sizeof(inp->name));
        inp->type = V4L2_INPUT_TYPE_CAMERA;
 
        return 0;
@@ -644,7 +644,7 @@ int sun6i_video_init(struct sun6i_video *video, struct sun6i_csi *csi,
        }
 
        /* Register video device */
-       strlcpy(vdev->name, name, sizeof(vdev->name));
+       strscpy(vdev->name, name, sizeof(vdev->name));
        vdev->release           = video_device_release_empty;
        vdev->fops              = &sun6i_video_fops;
        vdev->ioctl_ops         = &sun6i_video_ioctl_ops;
index 207e7e76c0480270a4bcf6e5d76e54371bcc4022..1e40eafec28405df8e13d8cab613a9a91294db3d 100644 (file)
@@ -1491,8 +1491,8 @@ handled:
 static int vpe_querycap(struct file *file, void *priv,
                        struct v4l2_capability *cap)
 {
-       strncpy(cap->driver, VPE_MODULE_NAME, sizeof(cap->driver) - 1);
-       strncpy(cap->card, VPE_MODULE_NAME, sizeof(cap->card) - 1);
+       strscpy(cap->driver, VPE_MODULE_NAME, sizeof(cap->driver));
+       strscpy(cap->card, VPE_MODULE_NAME, sizeof(cap->card));
        snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
                VPE_MODULE_NAME);
        cap->device_caps  = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING;
@@ -1519,7 +1519,7 @@ static int __enum_fmt(struct v4l2_fmtdesc *f, u32 type)
        if (!fmt)
                return -EINVAL;
 
-       strncpy(f->description, fmt->name, sizeof(f->description) - 1);
+       strscpy(f->description, fmt->name, sizeof(f->description));
        f->pixelformat = fmt->fourcc;
        return 0;
 }
index a5f8f74ea3bf48c33aa7abfc77046ad6d768fe95..bd01a9206aa69c38d09e30e52100b996f3797e01 100644 (file)
@@ -692,8 +692,8 @@ static const struct v4l2_fwht_pixfmt_info *find_fmt(u32 fmt)
 static int vidioc_querycap(struct file *file, void *priv,
                           struct v4l2_capability *cap)
 {
-       strncpy(cap->driver, VICODEC_NAME, sizeof(cap->driver) - 1);
-       strncpy(cap->card, VICODEC_NAME, sizeof(cap->card) - 1);
+       strscpy(cap->driver, VICODEC_NAME, sizeof(cap->driver));
+       strscpy(cap->card, VICODEC_NAME, sizeof(cap->card));
        snprintf(cap->bus_info, sizeof(cap->bus_info),
                        "platform:%s", VICODEC_NAME);
        return 0;
index d8763a8a7be65c87461090f3ed0e41a8978d5f32..243c82b5d537f8f28146c87cb8285c8fd5ba5cf9 100644 (file)
@@ -659,8 +659,8 @@ static void device_work(struct work_struct *w)
 static int vidioc_querycap(struct file *file, void *priv,
                           struct v4l2_capability *cap)
 {
-       strncpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver) - 1);
-       strncpy(cap->card, MEM2MEM_NAME, sizeof(cap->card) - 1);
+       strscpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver));
+       strscpy(cap->card, MEM2MEM_NAME, sizeof(cap->card));
        snprintf(cap->bus_info, sizeof(cap->bus_info),
                 "platform:%s", MEM2MEM_NAME);
        return 0;
index 342e0e6c103baceecee7fb4c13a85915b5d54d0a..7047df6f0e0e134af6a8d6e64f3ad37afdefbb5b 100644 (file)
@@ -681,7 +681,7 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
        dev->v4l2_dev.mdev = &dev->mdev;
 
        /* Initialize media device */
-       strlcpy(dev->mdev.model, VIVID_MODULE_NAME, sizeof(dev->mdev.model));
+       strscpy(dev->mdev.model, VIVID_MODULE_NAME, sizeof(dev->mdev.model));
        snprintf(dev->mdev.bus_info, sizeof(dev->mdev.bus_info),
                 "platform:%s-%03d", VIVID_MODULE_NAME, inst);
        dev->mdev.dev = &pdev->dev;
index f4a53f1e856e4930c28f95dfaa547879f6dead87..a8584371a32d98df55ba2f2864b17b17c38e86fa 100644 (file)
@@ -1272,7 +1272,7 @@ static int si4713_g_modulator(struct v4l2_subdev *sd, struct v4l2_modulator *vm)
        if (vm->index > 0)
                return -EINVAL;
 
-       strncpy(vm->name, "FM Modulator", 32);
+       strscpy(vm->name, "FM Modulator", sizeof(vm->name));
        vm->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LOW |
                V4L2_TUNER_CAP_RDS | V4L2_TUNER_CAP_RDS_CONTROLS;
 
index 19c6a0354ce000fa848b4ac154f0a731cd8b6b9c..abe98488be233c2736944915108d359d9afd9f77 100644 (file)
@@ -1132,7 +1132,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
        usb->usbdev = usbdev;
        usb_make_path(usbdev, go->bus_info, sizeof(go->bus_info));
        go->board_id = id->driver_info;
-       strncpy(go->name, name, sizeof(go->name));
+       strscpy(go->name, name, sizeof(go->name));
        if (board->flags & GO7007_USB_EZUSB)
                go->hpi_ops = &go7007_usb_ezusb_hpi_ops;
        else
@@ -1198,7 +1198,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
                                go->board_id = GO7007_BOARDID_ENDURA;
                                usb->board = board = &board_endura;
                                go->board_info = &board->main_info;
-                               strncpy(go->name, "Pelco Endura",
+                               strscpy(go->name, "Pelco Endura",
                                        sizeof(go->name));
                        } else {
                                u16 channel;
@@ -1232,21 +1232,21 @@ static int go7007_usb_probe(struct usb_interface *intf,
                case 1:
                        go->tuner_type = TUNER_SONY_BTF_PG472Z;
                        go->std = V4L2_STD_PAL;
-                       strncpy(go->name, "Plextor PX-TV402U-EU",
-                                       sizeof(go->name));
+                       strscpy(go->name, "Plextor PX-TV402U-EU",
+                               sizeof(go->name));
                        break;
                case 2:
                        go->tuner_type = TUNER_SONY_BTF_PK467Z;
                        go->std = V4L2_STD_NTSC_M_JP;
                        num_i2c_devs -= 2;
-                       strncpy(go->name, "Plextor PX-TV402U-JP",
-                                       sizeof(go->name));
+                       strscpy(go->name, "Plextor PX-TV402U-JP",
+                               sizeof(go->name));
                        break;
                case 3:
                        go->tuner_type = TUNER_SONY_BTF_PB463Z;
                        num_i2c_devs -= 2;
-                       strncpy(go->name, "Plextor PX-TV402U-NA",
-                                       sizeof(go->name));
+                       strscpy(go->name, "Plextor PX-TV402U-NA",
+                               sizeof(go->name));
                        break;
                default:
                        pr_debug("unable to detect tuner type!\n");
index 7a2781fa83e71bd1603852c4513faf2082081c87..bebdfcecf60020df31603f3ec85159e35bce2e60 100644 (file)
@@ -327,7 +327,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
        fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        fmt->flags = V4L2_FMT_FLAG_COMPRESSED;
 
-       strncpy(fmt->description, desc, sizeof(fmt->description));
+       strscpy(fmt->description, desc, sizeof(fmt->description));
 
        return 0;
 }
index e082086428a43a23c25c6a2b2dcf9a566903c612..3804aa3fb50fed559df13e19e903fada715b87a6 100644 (file)
@@ -769,8 +769,7 @@ static int vidioc_enum_input(struct file *file, void *_fh, struct v4l2_input *i)
 
        i->type = V4L2_INPUT_TYPE_CAMERA;
 
-       strncpy(i->name, iname[n], sizeof(i->name) - 1);
-       i->name[sizeof(i->name) - 1] = '\0';
+       strscpy(i->name, iname[n], sizeof(i->name));
 
        i->audioset = 1<<HDPVR_RCA_FRONT | 1<<HDPVR_RCA_BACK | 1<<HDPVR_SPDIF;
 
@@ -841,8 +840,7 @@ static int vidioc_enumaudio(struct file *file, void *priv,
 
        audio->capability = V4L2_AUDCAP_STEREO;
 
-       strncpy(audio->name, audio_iname[n], sizeof(audio->name) - 1);
-       audio->name[sizeof(audio->name) - 1] = '\0';
+       strscpy(audio->name, audio_iname[n], sizeof(audio->name));
 
        return 0;
 }
@@ -874,7 +872,6 @@ static int vidioc_g_audio(struct file *file, void *private_data,
        audio->index = dev->options.audio_input;
        audio->capability = V4L2_AUDCAP_STEREO;
        strscpy(audio->name, audio_iname[audio->index], sizeof(audio->name));
-       audio->name[sizeof(audio->name) - 1] = '\0';
        return 0;
 }
 
@@ -991,7 +988,8 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *private_data,
                return -EINVAL;
 
        f->flags = V4L2_FMT_FLAG_COMPRESSED;
-       strncpy(f->description, "MPEG2-TS with AVC/AAC streams", 32);
+       strscpy(f->description, "MPEG2-TS with AVC/AAC streams",
+               sizeof(f->description));
        f->pixelformat = V4L2_PIX_FMT_MPEG;
 
        return 0;
index b085b14f3f8778747eef3fb4a58c14edc66dc419..ea9ee74fa336590618defddb80e6a74601b02bb0 100644 (file)
@@ -435,7 +435,7 @@ static int pulse8_setup(struct pulse8 *pulse8, struct serio *serio,
        err = pulse8_send_and_wait(pulse8, cmd, 1, cmd[0], 0);
        if (err)
                return err;
-       strncpy(log_addrs->osd_name, data, 13);
+       strscpy(log_addrs->osd_name, data, sizeof(log_addrs->osd_name));
        dev_dbg(pulse8->dev, "OSD name: %s\n", log_addrs->osd_name);
 
        return 0;
@@ -566,7 +566,7 @@ static int pulse8_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr)
                char *osd_str = cmd + 1;
 
                cmd[0] = MSGCODE_SET_OSD_NAME;
-               strncpy(cmd + 1, adap->log_addrs.osd_name, 13);
+               strscpy(cmd + 1, adap->log_addrs.osd_name, sizeof(cmd) - 1);
                if (osd_len < 4) {
                        memset(osd_str + osd_len, ' ', 4 - osd_len);
                        osd_len = 4;
index 446a999dd2ce1519656914fb1e79b44225f7017c..51112b7988e434464fae81f8333e1be25681fad1 100644 (file)
@@ -2459,9 +2459,8 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
                if (!(qctrl.flags & V4L2_CTRL_FLAG_READ_ONLY)) {
                        ciptr->set_value = ctrl_cx2341x_set;
                }
-               strncpy(hdw->mpeg_ctrl_info[idx].desc,qctrl.name,
-                       PVR2_CTLD_INFO_DESC_SIZE);
-               hdw->mpeg_ctrl_info[idx].desc[PVR2_CTLD_INFO_DESC_SIZE-1] = 0;
+               strscpy(hdw->mpeg_ctrl_info[idx].desc, qctrl.name,
+                       sizeof(hdw->mpeg_ctrl_info[idx].desc));
                ciptr->default_value = qctrl.default_value;
                switch (qctrl.type) {
                default:
index 08d5b7aa3537164c91c866719d741eb21e3749ae..cb6668580d772644446c1150a60a93e8158bf04e 100644 (file)
@@ -284,7 +284,7 @@ static int pvr2_enumaudio(struct file *file, void *priv, struct v4l2_audio *vin)
 
        if (vin->index > 0)
                return -EINVAL;
-       strncpy(vin->name, "PVRUSB2 Audio", 14);
+       strscpy(vin->name, "PVRUSB2 Audio", sizeof(vin->name));
        vin->capability = V4L2_AUDCAP_STEREO;
        return 0;
 }
@@ -293,7 +293,7 @@ static int pvr2_g_audio(struct file *file, void *priv, struct v4l2_audio *vin)
 {
        /* pkt: FIXME: see above comment (VIDIOC_ENUMAUDIO) */
        vin->index = 0;
-       strncpy(vin->name, "PVRUSB2 Audio", 14);
+       strscpy(vin->name, "PVRUSB2 Audio", sizeof(vin->name));
        vin->capability = V4L2_AUDCAP_STEREO;
        return 0;
 }
index d9b02ff662598f0dd5307cea0e7eeb705664755c..09903ffb13ba4c566a12aa5b701021a30de1bdd4 100644 (file)
@@ -2404,7 +2404,7 @@ static int bcm2048_vidioc_g_audio(struct file *file, void *priv,
        if (audio->index > 1)
                return -EINVAL;
 
-       strncpy(audio->name, "Radio", 32);
+       strscpy(audio->name, "Radio", sizeof(audio->name));
        audio->capability = V4L2_AUDCAP_STEREO;
 
        return 0;
@@ -2432,7 +2432,7 @@ static int bcm2048_vidioc_g_tuner(struct file *file, void *priv,
        if (tuner->index > 0)
                return -EINVAL;
 
-       strncpy(tuner->name, "FM Receiver", 32);
+       strscpy(tuner->name, "FM Receiver", sizeof(tuner->name));
        tuner->type = V4L2_TUNER_RADIO;
        tuner->rangelow =
                dev_to_v4l2(bcm2048_get_region_bottom_frequency(bdev));
index 90a926891eb97d6ef8706d26483ae4b53ab72d02..1addb0893c572fa5dcf7971240af32500325b3f4 100644 (file)
@@ -63,7 +63,7 @@ static int imx_ic_probe(struct platform_device *pdev)
        priv->sd.owner = THIS_MODULE;
        priv->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
        priv->sd.grp_id = pdata->grp_id;
-       strncpy(priv->sd.name, pdata->sd_name, sizeof(priv->sd.name));
+       strscpy(priv->sd.name, pdata->sd_name, sizeof(priv->sd.name));
 
        ret = ic_ops[priv->task_id]->init(priv);
        if (ret)
index f8c84a07dad908d536ad2f2d420546b20a838863..5439b88dba201b4789b99e94d1b57032e96e922b 100644 (file)
@@ -964,7 +964,7 @@ static int imx_vdic_probe(struct platform_device *pdev)
        priv->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
        /* get our group id */
        priv->sd.grp_id = pdata->grp_id;
-       strncpy(priv->sd.name, pdata->sd_name, sizeof(priv->sd.name));
+       strscpy(priv->sd.name, pdata->sd_name, sizeof(priv->sd.name));
 
        mutex_init(&priv->lock);
 
index 04f88f9d6bb42c708d5ee7093c50bf9fbb0e2d1c..c998aa4dc73bca023bc85ec1b9198bcde182ffd8 100644 (file)
@@ -1526,8 +1526,8 @@ static int zoran_enum_fmt(struct zoran *zr, struct v4l2_fmtdesc *fmt, int flag)
 
        for (num = i = 0; i < NUM_FORMATS; i++) {
                if (zoran_formats[i].flags & flag && num++ == fmt->index) {
-                       strncpy(fmt->description, zoran_formats[i].name,
-                               sizeof(fmt->description) - 1);
+                       strscpy(fmt->description, zoran_formats[i].name,
+                               sizeof(fmt->description));
                        /* fmt struct pre-zeroed, so adding '\0' not needed */
                        fmt->pixelformat = zoran_formats[i].fourcc;
                        if (zoran_formats[i].flags & ZORAN_FORMAT_COMPRESSED)
@@ -2301,8 +2301,8 @@ static int zoran_enum_input(struct file *file, void *__fh,
        if (inp->index >= zr->card.inputs)
                return -EINVAL;
 
-       strncpy(inp->name, zr->card.input[inp->index].name,
-               sizeof(inp->name) - 1);
+       strscpy(inp->name, zr->card.input[inp->index].name,
+               sizeof(inp->name));
        inp->type = V4L2_INPUT_TYPE_CAMERA;
        inp->std = V4L2_STD_ALL;
 
@@ -2344,7 +2344,7 @@ static int zoran_enum_output(struct file *file, void *__fh,
 
        outp->index = 0;
        outp->type = V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY;
-       strncpy(outp->name, "Autodetect", sizeof(outp->name)-1);
+       strscpy(outp->name, "Autodetect", sizeof(outp->name));
 
        return 0;
 }