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