* [PATCH] input/joystick: magellan: Mark __nonstring look-up table
@ 2025-04-16 17:45 Kees Cook
2025-04-19 1:34 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2025-04-16 17:45 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Kees Cook, Erick Archer, Christophe JAILLET, linux-input,
linux-kernel, linux-hardening
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?";
| ^~~~~~~~~~~~~~~~~~
Add the annotation and While at it, mark the table as const too.
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Erick Archer <erick.archer@outlook.com>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: linux-input@vger.kernel.org
---
drivers/input/joystick/magellan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c
index 2eaa25c9c68c..7622638e5bb8 100644
--- a/drivers/input/joystick/magellan.c
+++ b/drivers/input/joystick/magellan.c
@@ -48,7 +48,7 @@ struct magellan {
static int magellan_crunch_nibbles(unsigned char *data, int count)
{
- static unsigned char nibbles[16] = "0AB3D56GH9:K<MN?";
+ static const unsigned char nibbles[16] __nonstring = "0AB3D56GH9:K<MN?";
do {
if (data[count] == nibbles[data[count] & 0xf])
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] input/joystick: magellan: Mark __nonstring look-up table
2025-04-16 17:45 [PATCH] input/joystick: magellan: Mark __nonstring look-up table Kees Cook
@ 2025-04-19 1:34 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2025-04-19 1:34 UTC (permalink / raw)
To: Kees Cook
Cc: Erick Archer, Christophe JAILLET, linux-input, linux-kernel,
linux-hardening
On Wed, Apr 16, 2025 at 10:45:17AM -0700, Kees Cook wrote:
> 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?";
> | ^~~~~~~~~~~~~~~~~~
>
> Add the annotation and While at it, mark the table as const too.
>
> Signed-off-by: Kees Cook <kees@kernel.org>
Applied, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-19 1:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-16 17:45 [PATCH] input/joystick: magellan: Mark __nonstring look-up table Kees Cook
2025-04-19 1:34 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).