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 = 0; | ||
988 | expr_list_for_each_sym(prop->expr, e, sym) | ||
989 | cnt++; | ||
990 | |||
991 | /* | ||
992 | * find a random value and set it to yes, | ||
993 | * set the rest to no so we have only one set | ||
994 | */ | ||
995 | def = (rand() % cnt); | ||
996 | |||
997 | cnt = 0; | ||
998 | expr_list_for_each_sym(prop->expr, e, sym) { | ||
999 | if (def == cnt++) { | ||
1000 | sym->def[S_DEF_USER].tri = yes; | ||
1001 | csym->def[S_DEF_USER].val = sym; | ||
1002 | } | ||
1003 | else { | ||
1004 | sym->def[S_DEF_USER].tri = no; | ||
1005 | } | ||
1006 | } | ||
1007 | csym->flags |= SYMBOL_DEF_USER; | ||
1008 | /* clear VALID to get value calculated */ | ||
1009 | csym->flags &= ~(SYMBOL_VALID); | ||
1010 | } | 1041 | } |
1011 | } | 1042 | } |
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 8f18e37892cb..330e7c0048a8 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c | |||
@@ -1087,7 +1087,7 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char * | |||
1087 | 1087 | ||
1088 | static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) | 1088 | static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) |
1089 | { | 1089 | { |
1090 | fwrite(str, strlen(str), 1, data); | 1090 | xfwrite(str, strlen(str), 1, data); |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | void expr_fprint(struct expr *e, FILE *out) | 1093 | void expr_fprint(struct expr *e, FILE *out) |
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 76db065ed72c..bdf71bd31412 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h | |||
@@ -72,6 +72,9 @@ void zconf_nextfile(const char *name); | |||
72 | int zconf_lineno(void); | 72 | int zconf_lineno(void); |
73 | char *zconf_curname(void); | 73 | char *zconf_curname(void); |
74 | 74 | ||
75 | /* conf.c */ | ||
76 | void xfgets(char *str, int size, FILE *in); | ||
77 | |||
75 | /* confdata.c */ | 78 | /* confdata.c */ |
76 | const char *conf_get_configname(void); | 79 | const char *conf_get_configname(void); |
77 | const char *conf_get_autoconfig_name(void); | 80 | const char *conf_get_autoconfig_name(void); |
@@ -80,6 +83,13 @@ void sym_set_change_count(int count); | |||
80 | void sym_add_change_count(int count); | 83 | void sym_add_change_count(int count); |
81 | void conf_set_all_new_symbols(enum conf_def_mode mode); | 84 | void conf_set_all_new_symbols(enum conf_def_mode mode); |
82 | 85 | ||
86 | /* confdata.c and expr.c */ | ||
87 | static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) | ||
88 | { | ||
89 | if (fwrite(str, len, count, out) < count) | ||
90 | fprintf(stderr, "\nError in writing or end of file.\n"); | ||
91 | } | ||
92 | |||
83 | /* kconfig_load.c */ | 93 | /* kconfig_load.c */ |
84 | void kconfig_load(void); | 94 | void kconfig_load(void); |
85 | 95 | ||
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 762caf80ce37..2ba71bcd38e6 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c | |||
@@ -676,6 +676,8 @@ static void *item_data(void) | |||
676 | struct mitem *mcur; | 676 | struct mitem *mcur; |
677 | 677 | ||
678 | cur = current_item(curses_menu); | 678 | cur = current_item(curses_menu); |
679 | if (!cur) | ||
680 | return NULL; | ||
679 | mcur = (struct mitem *) item_userptr(cur); | 681 | mcur = (struct mitem *) item_userptr(cur); |
680 | return mcur->usrptr; | 682 | return mcur->usrptr; |
681 | 683 | ||