diff mbox series

[1/7] media: allegro-dvt: increase buffer size in msg_type_name()

Message ID 20230922105036.3148784-2-hverkuil-cisco@xs4all.nl (mailing list archive)
State New, archived
Headers show
Series media: string truncate warnings: fix low-hanging fruit | expand

Commit Message

Hans Verkuil Sept. 22, 2023, 10:50 a.m. UTC
Fixes this compile error

drivers/media/platform/allegro-dvt/allegro-mail.c: In function 'msg_type_name':
drivers/media/platform/allegro-dvt/allegro-mail.c:37:48: warning: '%04x' directive output may be truncated writing between 4 and 8 bytes into a region of size 6 [-Wformat-truncation=]
   37 |                 snprintf(buf, sizeof(buf), "(0x%04x)", type);
      |                                                ^~~~
drivers/media/platform/allegro-dvt/allegro-mail.c:37:44: note: directive argument in the range [1, 4294967295]
   37 |                 snprintf(buf, sizeof(buf), "(0x%04x)", type);
      |                                            ^~~~~~~~~~
drivers/media/platform/allegro-dvt/allegro-mail.c:37:17: note: 'snprintf' output between 9 and 13 bytes into a destination of size 9
   37 |                 snprintf(buf, sizeof(buf), "(0x%04x)", type);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Michael Tretter <m.tretter@pengutronix.de>
---
 drivers/media/platform/allegro-dvt/allegro-mail.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Tretter Sept. 22, 2023, 11:55 a.m. UTC | #1
On Fri, 22 Sep 2023 12:50:30 +0200, Hans Verkuil wrote:
> Fixes this compile error
> 
> drivers/media/platform/allegro-dvt/allegro-mail.c: In function 'msg_type_name':
> drivers/media/platform/allegro-dvt/allegro-mail.c:37:48: warning: '%04x' directive output may be truncated writing between 4 and 8 bytes into a region of size 6 [-Wformat-truncation=]
>    37 |                 snprintf(buf, sizeof(buf), "(0x%04x)", type);
>       |                                                ^~~~
> drivers/media/platform/allegro-dvt/allegro-mail.c:37:44: note: directive argument in the range [1, 4294967295]
>    37 |                 snprintf(buf, sizeof(buf), "(0x%04x)", type);
>       |                                            ^~~~~~~~~~
> drivers/media/platform/allegro-dvt/allegro-mail.c:37:17: note: 'snprintf' output between 9 and 13 bytes into a destination of size 9
>    37 |                 snprintf(buf, sizeof(buf), "(0x%04x)", type);
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> Cc: Michael Tretter <m.tretter@pengutronix.de>

Reviewed-by: Michael Tretter <m.tretter@pengutronix.de>

> ---
>  drivers/media/platform/allegro-dvt/allegro-mail.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/allegro-dvt/allegro-mail.c b/drivers/media/platform/allegro-dvt/allegro-mail.c
> index 16effad10746..aadc947a77ae 100644
> --- a/drivers/media/platform/allegro-dvt/allegro-mail.c
> +++ b/drivers/media/platform/allegro-dvt/allegro-mail.c
> @@ -16,7 +16,7 @@
>  
>  const char *msg_type_name(enum mcu_msg_type type)
>  {
> -	static char buf[9];
> +	static char buf[13];
>  
>  	switch (type) {
>  	case MCU_MSG_TYPE_INIT:
> -- 
> 2.40.1
> 
>
diff mbox series

Patch

diff --git a/drivers/media/platform/allegro-dvt/allegro-mail.c b/drivers/media/platform/allegro-dvt/allegro-mail.c
index 16effad10746..aadc947a77ae 100644
--- a/drivers/media/platform/allegro-dvt/allegro-mail.c
+++ b/drivers/media/platform/allegro-dvt/allegro-mail.c
@@ -16,7 +16,7 @@ 
 
 const char *msg_type_name(enum mcu_msg_type type)
 {
-	static char buf[9];
+	static char buf[13];
 
 	switch (type) {
 	case MCU_MSG_TYPE_INIT: