[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220620084628.20894-2-johan@kernel.org>
Date: Mon, 20 Jun 2022 10:46:27 +0200
From: Johan Hovold <johan@...nel.org>
To: Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc: linux-input@...r.kernel.org, linux-kernel@...r.kernel.org,
Johan Hovold <johan@...nel.org>
Subject: [PATCH 1/2] Input: usbtouchscreen - suppress empty array warnings
When compile-testing the USB touchscreen driver without enabling any of
the device type options the usbtouch_dev_info array ends up being empty,
something which triggers compiler warning with -Warray-bounds
(gcc-11.3.0).
drivers/input/touchscreen/usbtouchscreen.c: In function 'usbtouch_probe':
drivers/input/touchscreen/usbtouchscreen.c:1668:16:warning: array subscript <unknown> is outside array bounds of 'struct usbtouch_device_info[0]' [-Warray-bounds]
1668 | type = &usbtouch_dev_info[id->driver_info];
Suppress the warnings by making sure that the array is always non-empty.
Signed-off-by: Johan Hovold <johan@...nel.org>
---
drivers/input/touchscreen/usbtouchscreen.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index 43c521f50c85..6683554f0e92 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -128,6 +128,7 @@ enum {
DEVTYPE_NEXIO,
DEVTYPE_ELO,
DEVTYPE_ETOUCH,
+ DEVTYPE_COUNT
};
#define USB_DEVICE_HID_CLASS(vend, prod) \
@@ -1379,6 +1380,7 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
.read_data = etouch_read_data,
},
#endif
+ [DEVTYPE_COUNT] = { } /* Make sure array is non-empty */
};
--
2.35.1
Powered by blists - more mailing lists