Skip to contentSkip to conversation

m68k/atari: Avoid VLA use in atari_switches_setup()

PATCH In review Geert Uytterhoeven 2 participants 4 messages Jan 7, 2019 – Jan 21, 2019 m68k architecture

lore
Share & tools
lore

Geert Uytterhoeven

author maintainer
#0 lore raw

PATCH 1/1 m68k/atari: Avoid VLA use in atari_switches_setup()

With gcc 7.3.0:

arch/m68k/atari/config.c: In function ‘atari_switches_setup’:
arch/m68k/atari/config.c:151:2: warning: ISO C90 forbids variable length array ‘switches’ [-Wvla]
char switches[strlen(str) + 1];
^~~~

Replace the variable size by the maximum kernel command line size (512 bytes), which is an upper limit for all suboptions.

---
 arch/m68k/atari/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/atari/config.c +1 -1
index bd96702a1ad09773..4fcc4b1df1c0f2b4 100644
@@ -148,7 +148,7 @@ int __init atari_parse_bootinfo(const struct bi_record *record)
 /* Parse the Atari-specific switches= option. */
 static int __init atari_switches_setup(char *str)
 {
-	char switches[strlen(str) + 1];
+	char switches[COMMAND_LINE_SIZE];
 	char *p;
 	int ovsc_shift;
 	char *args = switches;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 8 lines · Geert Uytterhoeven

With gcc 7.3.0:

arch/m68k/atari/config.c: In function ‘atari_switches_setup’:
arch/m68k/atari/config.c:151:2: warning: ISO C90 forbids variable length array ‘switches’ [-Wvla]
char switches[strlen(str) + 1];
^~~~

Quoted 4 lines

Replace the variable size by the maximum kernel command line size (512 bytes), which is an upper limit for all suboptions.

Seems fine as long as COMMAND_LINE_SIZE never grows a lot. Some architectures use 1024 or 2048, but m68k currently has 256 (you write 512 here).

Arnd

author maintainer
#2 lore raw

Hi Arnd,

Quoted 8 lines · Arnd Bergmann
Quoted 7 lines · Geert Uytterhoeven

With gcc 7.3.0:

arch/m68k/atari/config.c: In function ‘atari_switches_setup’:
arch/m68k/atari/config.c:151:2: warning: ISO C90 forbids variable length array ‘switches’ [-Wvla]
char switches[strlen(str) + 1];
^~~~

Quoted 6 lines
Quoted 4 lines

Replace the variable size by the maximum kernel command line size (512 bytes), which is an upper limit for all suboptions.

Seems fine as long as COMMAND_LINE_SIZE never grows a lot. Some

If that ever happens, it will be caught by -Wframe-larger-than=1024.

Quoted 2 lines

architectures use 1024 or 2048, but m68k currently has 256 (you write 512 here).

Thanks for noticing, will fix!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
author maintainer
#3 lore raw
Quoted 14 lines · Geert Uytterhoeven
Quoted 13 lines · Arnd Bergmann
Quoted 11 lines · Geert Uytterhoeven

With gcc 7.3.0:

arch/m68k/atari/config.c: In function ‘atari_switches_setup’:
arch/m68k/atari/config.c:151:2: warning: ISO C90 forbids variable length array ‘switches’ [-Wvla]
char switches[strlen(str) + 1];
^~~~

Replace the variable size by the maximum kernel command line size (512 bytes), which is an upper limit for all suboptions.

Quoted 8 lines
Quoted 1 line

Seems fine as long as COMMAND_LINE_SIZE never grows a lot. Some

If that ever happens, it will be caught by -Wframe-larger-than=1024.

Quoted 2 lines

architectures use 1024 or 2048, but m68k currently has 256 (you write 512 here).

Thanks for noticing, will fix!

Thanks, fixed, and applied and queued for v5.1.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds