kconfig: oldconfig shall not set symbols if it does not need to

Avoid setting the value if the symbol doesn't need to be changed or can't
be changed. Later choices may change the dependencies and thus the
possible input range.

make oldconfig from a 2.6.22 .config with CONFIG_HOTPLUG_CPU not set
was in some configurations setting CONFIG_HOTPLUG_CPU=y without asking,
even when there was no actual requirement for CONFIG_HOTPLUG_CPU.
This was triggered by SUSPEND_SMP that does a select HOTPLUG_CPU.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Tested-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

authored by Roman Zippel and committed by Sam Ravnborg f82f3f94 2f81eccb

+12 -9
+12 -9
scripts/kconfig/conf.c
··· 72 } 73 } 74 75 - static void conf_askvalue(struct symbol *sym, const char *def) 76 { 77 enum symbol_type type = sym_get_type(sym); 78 tristate val; ··· 87 printf("%s\n", def); 88 line[0] = '\n'; 89 line[1] = 0; 90 - return; 91 } 92 93 switch (input_mode) { ··· 97 case set_random: 98 if (sym_has_value(sym)) { 99 printf("%s\n", def); 100 - return; 101 } 102 break; 103 case ask_new: 104 case ask_silent: 105 if (sym_has_value(sym)) { 106 printf("%s\n", def); 107 - return; 108 } 109 check_stdin(); 110 case ask_all: 111 fflush(stdout); 112 fgets(line, 128, stdin); 113 - return; 114 case set_default: 115 printf("%s\n", def); 116 - return; 117 default: 118 break; 119 } ··· 123 case S_HEX: 124 case S_STRING: 125 printf("%s\n", def); 126 - return; 127 default: 128 ; 129 } ··· 174 break; 175 } 176 printf("%s", line); 177 } 178 179 int conf_string(struct menu *menu) ··· 188 def = sym_get_string_value(sym); 189 if (sym_get_string_value(sym)) 190 printf("[%s] ", def); 191 - conf_askvalue(sym, def); 192 switch (line[0]) { 193 case '\n': 194 break; ··· 242 if (menu_has_help(menu)) 243 printf("/?"); 244 printf("] "); 245 - conf_askvalue(sym, sym_get_string_value(sym)); 246 strip(line); 247 248 switch (line[0]) {
··· 72 } 73 } 74 75 + static int conf_askvalue(struct symbol *sym, const char *def) 76 { 77 enum symbol_type type = sym_get_type(sym); 78 tristate val; ··· 87 printf("%s\n", def); 88 line[0] = '\n'; 89 line[1] = 0; 90 + return 0; 91 } 92 93 switch (input_mode) { ··· 97 case set_random: 98 if (sym_has_value(sym)) { 99 printf("%s\n", def); 100 + return 0; 101 } 102 break; 103 case ask_new: 104 case ask_silent: 105 if (sym_has_value(sym)) { 106 printf("%s\n", def); 107 + return 0; 108 } 109 check_stdin(); 110 case ask_all: 111 fflush(stdout); 112 fgets(line, 128, stdin); 113 + return 1; 114 case set_default: 115 printf("%s\n", def); 116 + return 1; 117 default: 118 break; 119 } ··· 123 case S_HEX: 124 case S_STRING: 125 printf("%s\n", def); 126 + return 1; 127 default: 128 ; 129 } ··· 174 break; 175 } 176 printf("%s", line); 177 + return 1; 178 } 179 180 int conf_string(struct menu *menu) ··· 187 def = sym_get_string_value(sym); 188 if (sym_get_string_value(sym)) 189 printf("[%s] ", def); 190 + if (!conf_askvalue(sym, def)) 191 + return 0; 192 switch (line[0]) { 193 case '\n': 194 break; ··· 240 if (menu_has_help(menu)) 241 printf("/?"); 242 printf("] "); 243 + if (!conf_askvalue(sym, sym_get_string_value(sym))) 244 + return 0; 245 strip(line); 246 247 switch (line[0]) {