Skip to content

Commit dd09eb0

Browse files
keesgregkh
authored andcommitted
EISA: Increase length of device names
GCC 15's -Wunterminated-string-initialization warned about truncated name strings. Instead of marking them with the "nonstring" attribute[1], increase their length to correctly include enough space for the terminating NUL character, as they are used with %s format specifiers when showing resource allocations in /proc/ioports: seq_printf(m, "%*s%0*llx-%0*llx : %s\n", ..., r->name); The strings in eisa.ids have a max length of 73, and the 50 limit was an arbitrary limit that was removed back in 2008 with commit ca52a49 ("driver core: remove DEVICE_NAME_SIZE define"). Change the limit to 74 so nothing is truncated any more. Additionally fix the Makefile to use "if_changed" instead of "cmd" to detect changes to the command line used to generate the target, otherwise devlist.h won't be rebuilt. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117178 [1] Signed-off-by: Kees Cook <kees@kernel.org> Acked-by: Alejandro Colomar <alx@kernel.org> Link: https://lore.kernel.org/r/20250407172926.it.281-kees@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 577f88c commit dd09eb0

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

drivers/eisa/Makefile

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
# SPDX-License-Identifier: GPL-2.0
22
# Makefile for the Linux device tree
33

4-
obj-$(CONFIG_EISA) += eisa-bus.o
4+
obj-$(CONFIG_EISA) += devlist.h eisa-bus.o
55
obj-${CONFIG_EISA_PCI_EISA} += pci_eisa.o
66

77
# virtual_root.o should be the last EISA root device to initialize,
88
# so leave it at the end of the list.
99
obj-${CONFIG_EISA_VIRTUAL_ROOT} += virtual_root.o
1010

1111

12-
# Ugly hack to get DEVICE_NAME_SIZE value...
13-
DEVICE_NAME_SIZE = 50
14-
1512
$(obj)/eisa-bus.o: $(obj)/devlist.h
1613

1714
quiet_cmd_eisaid = GEN $@
18-
cmd_eisaid = sed -e '/^\#/D' -e 's/^\([[:alnum:]]\{7\}\) \+"\([^"]\{1,$(DEVICE_NAME_SIZE)\}\).*"/EISA_DEVINFO ("\1", "\2"),/' $< > $@
15+
cmd_eisaid = sed -e '/^\#/D' -e 's/^\([[:alnum:]]\{7\}\) \+"\([^"]*\)"/EISA_DEVINFO ("\1", "\2"),/' $< > $@
1916

2017
clean-files := devlist.h
21-
$(obj)/devlist.h: $(src)/eisa.ids include/linux/device.h
22-
$(call cmd,eisaid)
18+
$(obj)/devlist.h: $(src)/eisa.ids include/linux/device.h FORCE
19+
$(call if_changed,eisaid)

drivers/eisa/eisa-bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
struct eisa_device_info {
2323
struct eisa_device_id id;
24-
char name[50];
24+
char name[EISA_DEVICE_INFO_NAME_SIZE];
2525
};
2626

2727
#ifdef CONFIG_EISA_NAMES

include/linux/eisa.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
#define EISA_CONFIG_ENABLED 1
2929
#define EISA_CONFIG_FORCED 2
3030

31+
/* Chosen to hold the longest string in eisa.ids. */
32+
#define EISA_DEVICE_INFO_NAME_SIZE 74
33+
3134
/* There is not much we can say about an EISA device, apart from
3235
* signature, slot number, and base address. dma_mask is set by
3336
* default to parent device mask..*/
@@ -41,7 +44,7 @@ struct eisa_device {
4144
u64 dma_mask;
4245
struct device dev; /* generic device */
4346
#ifdef CONFIG_EISA_NAMES
44-
char pretty_name[50];
47+
char pretty_name[EISA_DEVICE_INFO_NAME_SIZE];
4548
#endif
4649
};
4750

0 commit comments

Comments
 (0)