Skip to content

Commit dc71768

Browse files
congwangtorvalds
authored andcommitted
uml: don't use a too long string literal
uml uses a concatenated string literal to store the contents of .config, but .config file content is varaible, it can be very long. Use an array of string literals instead. Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com> Cc: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 792dd4f commit dc71768

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

‎arch/um/kernel/Makefile‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ $(obj)/config.tmp: $(objtree)/.config FORCE
2828
$(call if_changed,quote1)
2929

3030
quiet_cmd_quote1 = QUOTE $@
31-
cmd_quote1 = sed -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n"/' \
31+
cmd_quote1 = sed -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n",/' \
3232
$< > $@
3333

3434
$(obj)/config.c: $(src)/config.c.in $(obj)/config.tmp FORCE
3535
$(call if_changed,quote2)
3636

3737
quiet_cmd_quote2 = QUOTE $@
3838
cmd_quote2 = sed -e '/CONFIG/{' \
39-
-e 's/"CONFIG"\;/""/' \
39+
-e 's/"CONFIG"//' \
4040
-e 'r $(obj)/config.tmp' \
4141
-e 'a \' \
42-
-e '""\;' \
42+
-e '""' \
4343
-e '}' \
4444
$< > $@

‎arch/um/kernel/config.c.in‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@
77
#include <stdlib.h>
88
#include "init.h"
99

10-
static __initdata char *config = "CONFIG";
10+
static __initdata const char *config[] = {
11+
"CONFIG"
12+
};
1113

1214
static int __init print_config(char *line, int *add)
1315
{
14-
printf("%s", config);
16+
int i;
17+
for (i = 0; i < sizeof(config)/sizeof(config[0]); i++)
18+
printf("%s", config[i]);
1519
exit(0);
1620
}
1721

0 commit comments

Comments
 (0)