diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-13 20:56:27 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-13 20:56:27 -0400 |
| commit | 090b710e8a0b7fe6f4752c5a439261f955075ebc (patch) | |
| tree | c85856f2955c3b0795db2c30ef0b334c0614e326 /scripts | |
| parent | 10041d2d14688e207d0d829095147aa82c1f211b (diff) | |
| parent | 4418a2b904805814bbd14b555d6add6a175f49f3 (diff) | |
Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6
* 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6:
kconfig: Fix warning: ignoring return value of 'fgets'
kconfig: Fix warning: ignoring return value of 'fwrite'
nconfig: Fix segfault when menu is empty
kconfig: fix tristate choice with minimal config
kconfig: fix savedefconfig for tristate choices
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/kconfig/conf.c | 15 | ||||
| -rw-r--r-- | scripts/kconfig/confdata.c | 111 | ||||
| -rw-r--r-- | scripts/kconfig/expr.c | 2 | ||||
| -rw-r--r-- | scripts/kconfig/lkc.h | 10 | ||||
| -rw-r--r-- | scripts/kconfig/nconf.c | 2 |
5 files changed, 97 insertions, 43 deletions
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 274f2716b03e..5b7c86ea43a1 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c | |||
| @@ -108,7 +108,7 @@ static int conf_askvalue(struct symbol *sym, const char *def) | |||
| 108 | check_stdin(); | 108 | check_stdin(); |
| 109 | case oldaskconfig: | 109 | case oldaskconfig: |
| 110 | fflush(stdout); | 110 | fflush(stdout); |
| 111 | fgets(line, 128, stdin); | 111 | xfgets(line, 128, stdin); |
| 112 | return 1; | 112 | return 1; |
| 113 | default: | 113 | default: |
| 114 | break; | 114 | break; |
| @@ -306,7 +306,7 @@ static int conf_choice(struct menu *menu) | |||
| 306 | check_stdin(); | 306 | check_stdin(); |
| 307 | case oldaskconfig: | 307 | case oldaskconfig: |
| 308 | fflush(stdout); | 308 | fflush(stdout); |
| 309 | fgets(line, 128, stdin); | 309 | xfgets(line, 128, stdin); |
| 310 | strip(line); | 310 | strip(line); |
| 311 | if (line[0] == '?') { | 311 | if (line[0] == '?') { |
| 312 | print_help(menu); | 312 | print_help(menu); |
| @@ -644,3 +644,14 @@ int main(int ac, char **av) | |||
| 644 | } | 644 | } |
| 645 | return 0; | 645 | return 0; |
| 646 | } | 646 | } |
| 647 | /* | ||
| 648 | * Helper function to facilitate fgets() by Jean Sacren. | ||
| 649 | */ | ||
| 650 | void xfgets(str, size, in) | ||
| 651 | char *str; | ||
| 652 | int size; | ||
| 653 | FILE *in; | ||
| 654 | { | ||
| 655 | if (fgets(str, size, in) == NULL) | ||
| 656 | fprintf(stderr, "\nError in reading or end of file.\n"); | ||
| 657 | } | ||
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index f81f263b64f2..c39327e60ea4 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
| @@ -412,7 +412,7 @@ static void conf_write_string(bool headerfile, const char *name, | |||
| 412 | while (1) { | 412 | while (1) { |
| 413 | l = strcspn(str, "\"\\"); | 413 | l = strcspn(str, "\"\\"); |
| 414 | if (l) { | 414 | if (l) { |
| 415 | fwrite(str, l, 1, out); | 415 | xfwrite(str, l, 1, out); |
| 416 | str += l; | 416 | str += l; |
| 417 | } | 417 | } |
| 418 | if (!*str) | 418 | if (!*str) |
| @@ -497,7 +497,7 @@ int conf_write_defconfig(const char *filename) | |||
| 497 | /* | 497 | /* |
| 498 | * If symbol is a choice value and equals to the | 498 | * If symbol is a choice value and equals to the |
| 499 | * default for a choice - skip. | 499 | * default for a choice - skip. |
| 500 | * But only if value equal to "y". | 500 | * But only if value is bool and equal to "y" . |
| 501 | */ | 501 | */ |
| 502 | if (sym_is_choice_value(sym)) { | 502 | if (sym_is_choice_value(sym)) { |
| 503 | struct symbol *cs; | 503 | struct symbol *cs; |
| @@ -506,9 +506,8 @@ int conf_write_defconfig(const char *filename) | |||
| 506 | cs = prop_get_symbol(sym_get_choice_prop(sym)); | 506 | cs = prop_get_symbol(sym_get_choice_prop(sym)); |
| 507 | ds = sym_choice_default(cs); | 507 | ds = sym_choice_default(cs); |
| 508 | if (sym == ds) { | 508 | if (sym == ds) { |
| 509 | if ((sym->type == S_BOOLEAN || | 509 | if ((sym->type == S_BOOLEAN) && |
| 510 | sym->type == S_TRISTATE) && | 510 | sym_get_tristate_value(sym) == yes) |
| 511 | sym_get_tristate_value(sym) == yes) | ||
| 512 | goto next_menu; | 511 | goto next_menu; |
| 513 | } | 512 | } |
| 514 | } | 513 | } |
| @@ -919,13 +918,73 @@ void conf_set_changed_callback(void (*fn)(void)) | |||
| 919 | conf_changed_callback = fn; | 918 | conf_changed_callback = fn; |
| 920 | } | 919 | } |
| 921 | 920 | ||
| 921 | static void randomize_choice_values(struct symbol *csym) | ||
| 922 | { | ||
| 923 | struct property *prop; | ||
| 924 | struct symbol *sym; | ||
| 925 | struct expr *e; | ||
| 926 | int cnt, def; | ||
| 922 | 927 | ||
| 923 | void conf_set_all_new_symbols(enum conf_def_mode mode) | 928 | /* |
| 929 | * If choice is mod then we may have more items slected | ||
| 930 | * and if no then no-one. | ||
| 931 | * In both cases stop. | ||
| 932 | */ | ||
| 933 | if (csym->curr.tri != yes) | ||
| 934 | return; | ||
| 935 | |||
| 936 | prop = sym_get_choice_prop(csym); | ||
| 937 | |||
| 938 | /* count entries in choice block */ | ||
| 939 | cnt = 0; | ||
| 940 | expr_list_for_each_sym(prop->expr, e, sym) | ||
| 941 | cnt++; | ||
| 942 | |||
| 943 | /* | ||
| 944 | * find a random value and set it to yes, | ||
| 945 | * set the rest to no so we have only one set | ||
| 946 | */ | ||
| 947 | def = (rand() % cnt); | ||
| 948 | |||
| 949 | cnt = 0; | ||
| 950 | expr_list_for_each_sym(prop->expr, e, sym) { | ||
| 951 | if (def == cnt++) { | ||
| 952 | sym->def[S_DEF_USER].tri = yes; | ||
| 953 | csym->def[S_DEF_USER].val = sym; | ||
| 954 | } | ||
| 955 | else { | ||
| 956 | sym->def[S_DEF_USER].tri = no; | ||
| 957 | } | ||
| 958 | } | ||
| 959 | csym->flags |= SYMBOL_DEF_USER; | ||
| 960 | /* clear VALID to get value calculated */ | ||
| 961 | csym->flags &= ~(SYMBOL_VALID); | ||
| 962 | } | ||
| 963 | |||
| 964 | static void set_all_choice_values(struct symbol *csym) | ||
| 924 | { | 965 | { |
| 925 | struct symbol *sym, *csym; | ||
| 926 | struct property *prop; | 966 | struct property *prop; |
| 967 | struct symbol *sym; | ||
| 927 | struct expr *e; | 968 | struct expr *e; |
| 928 | int i, cnt, def; | 969 | |
| 970 | prop = sym_get_choice_prop(csym); | ||
| 971 | |||
| 972 | /* | ||
| 973 | * Set all non-assinged choice values to no | ||
| 974 | */ | ||
| 975 | expr_list_for_each_sym(prop->expr, e, sym) { | ||
| 976 | if (!sym_has_value(sym)) | ||
| 977 | sym->def[S_DEF_USER].tri = no; | ||
| 978 | } | ||
| 979 | csym->flags |= SYMBOL_DEF_USER; | ||
| 980 | /* clear VALID to get value calculated */ | ||
| 981 | csym->flags &= ~(SYMBOL_VALID); | ||
| 982 | } | ||
| 983 | |||
| 984 | void conf_set_all_new_symbols(enum conf_def_mode mode) | ||
| 985 | { | ||
| 986 | struct symbol *sym, *csym; | ||
| 987 | int i, cnt; | ||
| 929 | 988 | ||
| 930 | for_all_symbols(i, sym) { | 989 | for_all_symbols(i, sym) { |
| 931 | if (sym_has_value(sym)) | 990 | if (sym_has_value(sym)) |
| @@ -961,8 +1020,6 @@ void conf_set_all_new_symbols(enum conf_def_mode mode) | |||
| 961 | 1020 | ||
| 962 | sym_clear_all_valid(); | 1021 | sym_clear_all_valid(); |
| 963 | 1022 | ||
| 964 | if (mode != def_random) | ||
| 965 | return; | ||
| 966 | /* | 1023 | /* |
| 967 | * We have different type of choice blocks. | 1024 | * We have different type of choice blocks. |
| 968 | * If curr.tri equal to mod then we can select several | 1025 | * If curr.tri equal to mod then we can select several |
| @@ -977,35 +1034,9 @@ void conf_set_all_new_symbols(enum conf_def_mode mode) | |||
| 977 | continue; | 1034 | continue; |
| 978 | 1035 | ||
| 979 | sym_calc_value(csym); | 1036 | sym_calc_value(csym); |
| 980 | 1037 | if (mode == def_random) | |
| 981 | if (csym->curr.tri != yes) | 1038 | randomize_choice_values(csym); |
| 982 | continue; | 1039 | else |
| 983 | 1040 | set_all_choice_values(csym); | |
| 984 | prop = sym_get_choice_prop(csym); | ||
| 985 | |||
| 986 | /* count entries in choice block */ | ||
| 987 | cnt = | ||
