All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
To: linux-media@vger.kernel.org
Cc: Arnd Bergmann <arnd@kernel.org>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
	Philipp Zabel <p.zabel@pengutronix.de>
Subject: [PATCHv2 22/23] media: verisilicon: replace snprintf with strscpy+strlcat
Date: Sat, 23 Sep 2023 17:21:06 +0200	[thread overview]
Message-ID: <20230923152107.283289-23-hverkuil-cisco@xs4all.nl> (raw)
In-Reply-To: <20230923152107.283289-1-hverkuil-cisco@xs4all.nl>

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>
Cc: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/media/platform/verisilicon/hantro_drv.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 50ec24c753e9..a9fa05ac56a9 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -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;
-- 
2.40.1


  parent reply	other threads:[~2023-09-23 15:21 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-23 15:20 [PATCHv2 00/23] media: fix all string truncate warnings Hans Verkuil
2023-09-23 15:20 ` [PATCHv2 01/23] media: allegro-dvt: increase buffer size in msg_type_name() Hans Verkuil
2023-09-23 15:20 ` [PATCHv2 02/23] media: cadence: increase buffer size in csi2tx_get_resources() Hans Verkuil
2023-09-23 15:20 ` [PATCHv2 03/23] media: atomisp: ia_ccs_debug.c: increase enable_info buffer Hans Verkuil
2023-09-23 15:20 ` [PATCHv2 04/23] media: vivid: avoid integer overflow Hans Verkuil
2023-09-23 15:20 ` [PATCHv2 05/23] media: ipu-bridge: increase sensor_name size Hans Verkuil
2023-09-23 15:20 ` [PATCHv2 06/23] media: cx18: increase in_workq_name size Hans Verkuil
2023-09-23 15:20 ` [PATCHv2 07/23] media: rc: ati_remote: increase mouse_name buffer size Hans Verkuil
2023-09-23 15:20 ` [PATCHv2 08/23] media: cec.h: increase input_phys buffer Hans Verkuil
2023-09-23 15:20 ` [PATCHv2 09/23] media: renesas-ceu: keep input name simple Hans Verkuil
2023-09-23 15:20 ` [PATCHv2 10/23] media: zoran: increase name size Hans Verkuil
2023-09-23 15:20 ` [PATCHv2 11/23] media: v4l2-dev.h: increase struct video_device " Hans Verkuil
2023-09-24 10:55   ` Sakari Ailus
2023-09-25  6:28     ` Hans Verkuil
2023-09-23 15:20 ` [PATCHv2 12/23] media: v4l2-subdev.h: increase struct v4l2_subdev " Hans Verkuil
2023-09-23 18:11   ` Laurent Pinchart
2023-09-25  6:26     ` Hans Verkuil
2023-09-25  6:51       ` Arnd Bergmann
2023-09-23 15:20 ` [PATCHv2 13/23] media: use sizeof() instead of V4L2_SUBDEV_NAME_SIZE Hans Verkuil
2023-09-23 18:06   ` Laurent Pinchart
2023-09-23 19:33   ` Niklas Söderlund
2023-09-25  7:42   ` Maxime Ripard
2023-09-25 16:51   ` Luca Ceresoli
2023-09-26 10:29     ` Luca Ceresoli
2023-09-23 15:20 ` [PATCHv2 14/23] media: v4l2-device.h: drop V4L2_DEVICE_NAME_SIZE Hans Verkuil
2023-09-23 15:20 ` [PATCHv2 15/23] media: vivid: use VIVID_MODULE_NAME to fill bus_info Hans Verkuil
2023-09-23 15:21 ` [PATCHv2 16/23] media: microchip: don't set bus_info Hans Verkuil
2023-09-25 12:01   ` Nicolas Ferre
2023-09-23 15:21 ` [PATCHv2 17/23] media: rcar_drif: use explicit name for bus_info Hans Verkuil
2023-09-23 15:21 ` [PATCHv2 18/23] media: am437x: don't fill in bus_info Hans Verkuil
2023-09-25  7:45   ` Lad, Prabhakar
2023-09-23 15:21 ` [PATCHv2 19/23] media: atmel: drop bus_info Hans Verkuil
2023-09-25 12:01   ` Nicolas Ferre
2023-09-23 15:21 ` [PATCHv2 20/23] media: radio-isa: use dev_name to fill in bus_info Hans Verkuil
2023-09-23 15:21 ` [PATCHv2 21/23] media: radio-miropcm20: set bus_info to explicit name Hans Verkuil
2023-09-23 15:21 ` Hans Verkuil [this message]
2023-09-23 15:21 ` [PATCHv2 23/23] media: radio-si476x: don't fill in bus_info Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230923152107.283289-23-hverkuil-cisco@xs4all.nl \
    --to=hverkuil-cisco@xs4all.nl \
    --cc=arnd@kernel.org \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=linux-media@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.