Thread (2 messages) 2 messages, 2 authors, 2021-10-05

Re: [PATCH] [RESEND] [v2] Input: analog - fix invalid snprintf() call

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2021-10-05 20:28:17
Also in: lkml

On Mon, Sep 27, 2021 at 12:14:06PM +0200, Arnd Bergmann wrote:
From: Arnd Bergmann <arnd@arndb.de>

Overlapping input and output arguments to snprintf() are
undefined behavior in C99:

drivers/input/joystick/analog.c: In function 'analog_name':
drivers/input/joystick/analog.c:428:3: error: 'snprintf' argument 4 overlaps destination object 'analog' [-Werror=restrict]
  428 |   snprintf(analog->name, sizeof(analog->name), "%s %d-hat",
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  429 |     analog->name, hweight16(analog->mask & ANALOG_HATS_ALL));
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/input/joystick/analog.c:420:40: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  420 | static void analog_name(struct analog *analog)
      |                         ~~~~~~~~~~~~~~~^~~~~~

Change this function to use the simpler seq_buf interface instead.

Cc: Rasmus Villemoes <redacted>
Link: https://lore.kernel.org/all/20210323131456.2600132-1-arnd@kernel.org/ (local)
Link: https://lore.kernel.org/all/20210324131959.2089129-1-arnd@kernel.org/ (local)
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Applied, thank you.

-- 
Dmitry
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help