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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 27, 2021 at 12:14:06PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
> 
> 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 <rasmus.villemoes@xxxxxxxxx>
> Link: https://lore.kernel.org/all/20210323131456.2600132-1-arnd@xxxxxxxxxx/
> Link: https://lore.kernel.org/all/20210324131959.2089129-1-arnd@xxxxxxxxxx/
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>

Applied, thank you.

-- 
Dmitry



[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux