diff mbox series

[7/7] media: rc: ati_remote: increase mouse_name buffer size

Message ID 20230922105036.3148784-8-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 compiler warning:

drivers/media/rc/ati_remote.c: In function 'ati_remote_probe':
drivers/media/rc/ati_remote.c:876:21: warning: ' mouse' directive output may be truncated writing 6 bytes into a region of size between 1 and 80 [-Wformat-truncation=]
  876 |                  "%s mouse", ati_remote->rc_name);
      |                     ^~~~~~
drivers/media/rc/ati_remote.c:875:9: note: 'snprintf' output between 7 and 86 bytes into a destination of size 80
  875 |         snprintf(ati_remote->mouse_name, sizeof(ati_remote->mouse_name),
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  876 |                  "%s mouse", ati_remote->rc_name);
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Sean Young <sean@mess.org>
---
 drivers/media/rc/ati_remote.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sean Young Sept. 22, 2023, 10:59 a.m. UTC | #1
On Fri, Sep 22, 2023 at 12:50:36PM +0200, Hans Verkuil wrote:
> Fixes this compiler warning:
> 
> drivers/media/rc/ati_remote.c: In function 'ati_remote_probe':
> drivers/media/rc/ati_remote.c:876:21: warning: ' mouse' directive output may be truncated writing 6 bytes into a region of size between 1 and 80 [-Wformat-truncation=]
>   876 |                  "%s mouse", ati_remote->rc_name);
>       |                     ^~~~~~
> drivers/media/rc/ati_remote.c:875:9: note: 'snprintf' output between 7 and 86 bytes into a destination of size 80
>   875 |         snprintf(ati_remote->mouse_name, sizeof(ati_remote->mouse_name),
>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   876 |                  "%s mouse", ati_remote->rc_name);
>       |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> Cc: Sean Young <sean@mess.org>

I was looking at this problem this morning - you beat me to it. :)

Reviewed-by: Sean Young <sean@mess.org>

Thanks
Sean

> ---
>  drivers/media/rc/ati_remote.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c
> index fff4dd48eaca..d7721e60776e 100644
> --- a/drivers/media/rc/ati_remote.c
> +++ b/drivers/media/rc/ati_remote.c
> @@ -251,7 +251,7 @@ struct ati_remote {
>  
>  	char rc_name[NAME_BUFSIZE];
>  	char rc_phys[NAME_BUFSIZE];
> -	char mouse_name[NAME_BUFSIZE];
> +	char mouse_name[NAME_BUFSIZE + 6];
>  	char mouse_phys[NAME_BUFSIZE];
>  
>  	wait_queue_head_t wait;
> -- 
> 2.40.1
diff mbox series

Patch

diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c
index fff4dd48eaca..d7721e60776e 100644
--- a/drivers/media/rc/ati_remote.c
+++ b/drivers/media/rc/ati_remote.c
@@ -251,7 +251,7 @@  struct ati_remote {
 
 	char rc_name[NAME_BUFSIZE];
 	char rc_phys[NAME_BUFSIZE];
-	char mouse_name[NAME_BUFSIZE];
+	char mouse_name[NAME_BUFSIZE + 6];
 	char mouse_phys[NAME_BUFSIZE];
 
 	wait_queue_head_t wait;