Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: verisilicon: replace snprintf with strscpy+strlcat

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>

+3 -2
+3 -2
drivers/media/platform/verisilicon/hantro_drv.c
··· 899 899 vfd->vfl_dir = VFL_DIR_M2M; 900 900 vfd->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M_MPLANE; 901 901 vfd->ioctl_ops = &hantro_ioctl_ops; 902 - snprintf(vfd->name, sizeof(vfd->name), "%s-%s", match->compatible, 903 - funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER ? "enc" : "dec"); 902 + strscpy(vfd->name, match->compatible, sizeof(vfd->name)); 903 + strlcat(vfd->name, funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER ? 904 + "-enc" : "-dec", sizeof(vfd->name)); 904 905 905 906 if (funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER) { 906 907 vpu->encoder = func;