Skip to content

Commit 05e8d26

Browse files
committed
gcc-15: add '__nonstring' markers to byte arrays
All of these cases are perfectly valid and good traditional C, but hit by the "you're not NUL-terminating your byte array" warning. And none of the cases want any terminating NUL character. Mark them __nonstring to shut up gcc-15 (and in the case of the ak8974 magnetometer driver, I just removed the explicit array size and let gcc expand the 3-byte and 6-byte arrays by one extra byte, because it was the simpler change). Signed-off-by: Linus Torvalds <[email protected]>
1 parent be913e7 commit 05e8d26

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

drivers/iio/magnetometer/ak8974.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,8 @@ static int ak8974_detect(struct ak8974 *ak8974)
535535
fab_data2, sizeof(fab_data2));
536536

537537
for (i = 0; i < 3; ++i) {
538-
static const char axis[3] = "XYZ";
539-
static const char pgaxis[6] = "ZYZXYX";
538+
static const char axis[] = "XYZ";
539+
static const char pgaxis[] = "ZYZXYX";
540540
unsigned offz = le16_to_cpu(fab_data2[i]) & 0x7F;
541541
unsigned fine = le16_to_cpu(fab_data1[i]);
542542
unsigned sens = le16_to_cpu(fab_data1[i + 3]);

drivers/input/joystick/magellan.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct magellan {
4848

4949
static int magellan_crunch_nibbles(unsigned char *data, int count)
5050
{
51-
static unsigned char nibbles[16] = "0AB3D56GH9:K<MN?";
51+
static unsigned char nibbles[16] __nonstring = "0AB3D56GH9:K<MN?";
5252

5353
do {
5454
if (data[count] == nibbles[data[count] & 0xf])

drivers/net/wireless/ath/carl9170/fw.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "fwcmd.h"
1616
#include "version.h"
1717

18-
static const u8 otus_magic[4] = { OTUS_MAGIC };
18+
static const u8 otus_magic[4] __nonstring = { OTUS_MAGIC };
1919

2020
static const void *carl9170_fw_find_desc(struct ar9170 *ar, const u8 descid[4],
2121
const unsigned int len, const u8 compatible_revision)

fs/cachefiles/key.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <linux/slab.h>
99
#include "internal.h"
1010

11-
static const char cachefiles_charmap[64] =
11+
static const char cachefiles_charmap[64] __nonstring =
1212
"0123456789" /* 0 - 9 */
1313
"abcdefghijklmnopqrstuvwxyz" /* 10 - 35 */
1414
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" /* 36 - 61 */

0 commit comments

Comments
 (0)