Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

input/joystick: magellan: Mark __nonstring look-up table const

GCC 15's new -Wunterminated-string-initialization notices that the
16 character lookup table "nibbles" (which is not used as a C-String)
needs to be marked as "nonstring":

drivers/input/joystick/magellan.c: In function 'magellan_crunch_nibbles':
drivers/input/joystick/magellan.c:51:44: warning: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (17 chars into 16 available) [-Wunterminated-string-initialization]
51 | static unsigned char nibbles[16] = "0AB3D56GH9:K<MN?";
| ^~~~~~~~~~~~~~~~~~

While the annotation was added in commit 48709ee1fa9a ("gcc-15: add
'__nonstring' markers to byte arrays") also mark the table as const.

Signed-off-by: Kees Cook <kees@kernel.org>

+1 -1
+1 -1
drivers/input/joystick/magellan.c
··· 48 48 49 49 static int magellan_crunch_nibbles(unsigned char *data, int count) 50 50 { 51 - static unsigned char nibbles[16] __nonstring = "0AB3D56GH9:K<MN?"; 51 + static const unsigned char nibbles[16] __nonstring = "0AB3D56GH9:K<MN?"; 52 52 53 53 do { 54 54 if (data[count] == nibbles[data[count] & 0xf])