]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
media: verisilicon: replace snprintf with strscpy+strlcat
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Sat, 23 Sep 2023 15:21:06 +0000 (17:21 +0200)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 27 Sep 2023 08:47:23 +0000 (10:47 +0200)
Fixes this warning:

drivers/media/platform/verisilicon/hantro_drv.c: In function 'hantro_add_func':
drivers/media/platform/verisilicon/hantro_drv.c:902:49: warning: '%s' directive output may be truncated writing up to 127 bytes into a region of size 64 [-Wformat-truncation=]
  902 |         snprintf(vfd->name, sizeof(vfd->name), "%s-%s", match->compatible,
      |                                                 ^~
drivers/media/platform/verisilicon/hantro_drv.c:902:9: note: 'snprintf' output between 5 and 132 bytes into a destination of size 64
  902 |         snprintf(vfd->name, sizeof(vfd->name), "%s-%s", match->compatible,
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  903 |                  funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER ? "enc" : "dec");
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/platform/verisilicon/hantro_drv.c:902:49: warning: '%s' directive output may be truncated writing up to 127 bytes into a region of size 64 [-Wformat-truncation=]
  902 |         snprintf(vfd->name, sizeof(vfd->name), "%s-%s", match->compatible,
      |                                                 ^~
drivers/media/platform/verisilicon/hantro_drv.c:902:9: note: 'snprintf' output between 5 and 132 bytes into a destination of size 64
  902 |         snprintf(vfd->name, sizeof(vfd->name), "%s-%s", match->compatible,
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  903 |                  funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER ? "enc" : "dec");
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/platform/verisilicon/hantro_drv.c

index 50ec24c753e9ec7b4cd8c646a5390ea5a801c5c4..a9fa05ac56a9b60367c778ffdb097e8a2a48e6af 100644 (file)
@@ -899,8 +899,9 @@ static int hantro_add_func(struct hantro_dev *vpu, unsigned int funcid)
        vfd->vfl_dir = VFL_DIR_M2M;
        vfd->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M_MPLANE;
        vfd->ioctl_ops = &hantro_ioctl_ops;
-       snprintf(vfd->name, sizeof(vfd->name), "%s-%s", match->compatible,
-                funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER ? "enc" : "dec");
+       strscpy(vfd->name, match->compatible, sizeof(vfd->name));
+       strlcat(vfd->name, funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER ?
+               "-enc" : "-dec", sizeof(vfd->name));
 
        if (funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER) {
                vpu->encoder = func;