Skip to content

Commit

Permalink
uml: don't use a too long string literal
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Jeff Dike <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
congwang authored and torvalds committed Apr 1, 2009
1 parent 792dd4f commit dc71768
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions arch/um/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ $(obj)/config.tmp: $(objtree)/.config FORCE
$(call if_changed,quote1)

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

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

quiet_cmd_quote2 = QUOTE $@
cmd_quote2 = sed -e '/CONFIG/{' \
-e 's/"CONFIG"\;/""/' \
-e 's/"CONFIG"//' \
-e 'r $(obj)/config.tmp' \
-e 'a \' \
-e '""\;' \
-e '""' \
-e '}' \
$< > $@
8 changes: 6 additions & 2 deletions arch/um/kernel/config.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
#include <stdlib.h>
#include "init.h"

static __initdata char *config = "CONFIG";
static __initdata const char *config[] = {
"CONFIG"
};

static int __init print_config(char *line, int *add)
{
printf("%s", config);
int i;
for (i = 0; i < sizeof(config)/sizeof(config[0]); i++)
printf("%s", config[i]);
exit(0);
}

Expand Down

0 comments on commit dc71768

Please sign in to comment.