]> Git Repo - linux.git/commit
gpio: acpi: work around false-positive -Wstring-overflow warning
authorArnd Bergmann <[email protected]>
Wed, 6 Sep 2017 15:47:45 +0000 (17:47 +0200)
committerLinus Walleij <[email protected]>
Tue, 19 Sep 2017 07:39:10 +0000 (09:39 +0200)
commite40a3ae1f794a35c4af3746291ed6fedc1fa0f6f
treed2f50a1b41e2fb2dd76faf783a9ee59beb3c558f
parent311de3ce96f453a5a6edb3066eb6109cc07e81d2
gpio: acpi: work around false-positive -Wstring-overflow warning

gcc-7 notices that the pin_table is an array of 16-bit numbers,
but fails to take the following range check into account:

drivers/gpio/gpiolib-acpi.c: In function 'acpi_gpiochip_request_interrupt':
drivers/gpio/gpiolib-acpi.c:206:24: warning: '%02X' directive writing between 2 and 4 bytes into a region of size 3 [-Wformat-overflow=]
   sprintf(ev_name, "_%c%02X",
                        ^~~~
drivers/gpio/gpiolib-acpi.c:206:20: note: directive argument in the range [0, 65535]
   sprintf(ev_name, "_%c%02X",
                    ^~~~~~~~~
drivers/gpio/gpiolib-acpi.c:206:3: note: 'sprintf' output between 5 and 7 bytes into a destination of size 5
   sprintf(ev_name, "_%c%02X",
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    agpio->triggering == ACPI_EDGE_SENSITIVE ? 'E' : 'L',
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    pin);
    ~~~~

As suggested by Andy, this changes the format string to have a fixed length.
Since modifying the range check did not help, I also opened a bug against
gcc, see link below.

Fixes: 0d1c28a449c6 ("gpiolib-acpi: Add ACPI5 event model support to gpio.")
Cc: Andy Shevchenko <[email protected]>
Link: https://patchwork.kernel.org/patch/9840801/
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82123
Signed-off-by: Arnd Bergmann <[email protected]>
Acked-by: Mika Westerberg <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
drivers/gpio/gpiolib-acpi.c
This page took 0.048107 seconds and 4 git commands to generate.