aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/confdata.c
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2009-03-15 06:05:12 -0400
committerSam Ravnborg <sam@ravnborg.org>2009-03-15 17:54:57 -0400
commit184832c981fd38b1052f2dfa0262e793fa6c67d3 (patch)
treebe1f3abb2f83fb20997ffcf770441610114bbf3f /scripts/kconfig/confdata.c
parent5bee17f18b595937e6beafeee5197868a3f74a06 (diff)
kconfig: fix randconfig for choice blocks
Ingo Molnar reported that 'make randconfig' was not covering choice blocks properly, resulting in certain config options being left out of randconfig testing altogether. With the following patch we: - properly randomize choice value for normal choice blocks - properly randomize for multi choice blocks - added several comments to explain what is going on The root cause of the bug was that SYMBOL_VALID was set on the symbol representing the choice block so clearing this did the trick initially. But testign revealed a few more issues that is now fixed. Reported-by: Ingo Molnar <mingo@elte.hu> Cc: Ingo Molnar <mingo@elte.hu> Cc: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/kconfig/confdata.c')
-rw-r--r--scripts/kconfig/confdata.c51
1 files changed, 36 insertions, 15 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 830d9eae11f9..273d73888f9d 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -843,7 +843,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
843 default: 843 default:
844 continue; 844 continue;
845 } 845 }
846 if (!sym_is_choice(sym) || mode != def_random) 846 if (!(sym_is_choice(sym) && mode == def_random))
847 sym->flags |= SYMBOL_DEF_USER; 847 sym->flags |= SYMBOL_DEF_USER;
848 break; 848 break;
849 default: 849 default:
@@ -856,28 +856,49 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
856 856
857 if (mode != def_random) 857 if (mode != def_random)
858 return; 858 return;
859 859 /*
860 * We have different type of choice blocks.
861 * If curr.tri equal to mod then we can select several
862 * choice symbols in one block.
863 * In this case we do nothing.
864 * If curr.tri equal yes then only one symbol can be
865 * selected in a choice block and we set it to yes,
866 * and the rest to no.
867 */
860 for_all_symbols(i, csym) { 868 for_all_symbols(i, csym) {
861 if (sym_has_value(csym) || !sym_is_choice(csym)) 869 if (sym_has_value(csym) || !sym_is_choice(csym))
862 continue; 870 continue;
863 871
864 sym_calc_value(csym); 872 sym_calc_value(csym);
873
874 if (csym->curr.tri != yes)
875 continue;
876
865 prop = sym_get_choice_prop(csym); 877 prop = sym_get_choice_prop(csym);
866 def = -1; 878
867 while (1) { 879 /* count entries in choice block */
868 cnt = 0; 880 cnt = 0;
869 expr_list_for_each_sym(prop->expr, e, sym) { 881 expr_list_for_each_sym(prop->expr, e, sym)
870 if (sym->visible == no) 882 cnt++;
871 continue; 883
872 if (def == cnt++) { 884 /*
873 csym->def[S_DEF_USER].val = sym; 885 * find a random value and set it to yes,
874 break; 886 * set the rest to no so we have only one set
875 } 887 */
888 def = (rand() % cnt);
889
890 cnt = 0;
891 expr_list_for_each_sym(prop->expr, e, sym) {
892 if (def == cnt++) {
893 sym->def[S_DEF_USER].tri = yes;
894 csym->def[S_DEF_USER].val = sym;
895 }
896 else {
897 sym->def[S_DEF_USER].tri = no;
876 } 898 }
877 if (def >= 0 || cnt < 2)
878 break;
879 def = (rand() % cnt) + 1;
880 } 899 }
881 csym->flags |= SYMBOL_DEF_USER; 900 csym->flags |= SYMBOL_DEF_USER;
901 /* clear VALID to get value calculated */
902 csym->flags &= ~(SYMBOL_VALID);
882 } 903 }
883} 904}