diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/kconfig/confdata.c | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 89274809a826..fc45fc137875 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
@@ -1107,7 +1107,51 @@ static void set_all_choice_values(struct symbol *csym) | |||
1107 | void conf_set_all_new_symbols(enum conf_def_mode mode) | 1107 | void conf_set_all_new_symbols(enum conf_def_mode mode) |
1108 | { | 1108 | { |
1109 | struct symbol *sym, *csym; | 1109 | struct symbol *sym, *csym; |
1110 | int i, cnt; | 1110 | int i, cnt, pby, pty, ptm; /* pby: probability of boolean = y |
1111 | * pty: probability of tristate = y | ||
1112 | * ptm: probability of tristate = m | ||
1113 | */ | ||
1114 | |||
1115 | pby = 50; pty = ptm = 33; /* can't go as the default in switch-case | ||
1116 | * below, otherwise gcc whines about | ||
1117 | * -Wmaybe-uninitialized */ | ||
1118 | if (mode == def_random) { | ||
1119 | int n, p[3]; | ||
1120 | char *env = getenv("KCONFIG_PROBABILITY"); | ||
1121 | n = 0; | ||
1122 | while( env && *env ) { | ||
1123 | char *endp; | ||
1124 | int tmp = strtol( env, &endp, 10 ); | ||
1125 | if( tmp >= 0 && tmp <= 100 ) { | ||
1126 | p[n++] = tmp; | ||
1127 | } else { | ||
1128 | errno = ERANGE; | ||
1129 | perror( "KCONFIG_PROBABILITY" ); | ||
1130 | exit( 1 ); | ||
1131 | } | ||
1132 | env = (*endp == ':') ? endp+1 : endp; | ||
1133 | if( n >=3 ) { | ||
1134 | break; | ||
1135 | } | ||
1136 | } | ||
1137 | switch( n ) { | ||
1138 | case 1: | ||
1139 | pby = p[0]; ptm = pby/2; pty = pby-ptm; | ||
1140 | break; | ||
1141 | case 2: | ||
1142 | pty = p[0]; ptm = p[1]; pby = pty + ptm; | ||
1143 | break; | ||
1144 | case 3: | ||
1145 | pby = p[0]; pty = p[1]; ptm = p[2]; | ||
1146 | break; | ||
1147 | } | ||
1148 | |||
1149 | if( pty+ptm > 100 ) { | ||
1150 | errno = ERANGE; | ||
1151 | perror( "KCONFIG_PROBABILITY" ); | ||
1152 | exit( 1 ); | ||
1153 | } | ||
1154 | } | ||
1111 | 1155 | ||
1112 | for_all_symbols(i, sym) { | 1156 | for_all_symbols(i, sym) { |
1113 | if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID)) | 1157 | if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID)) |
@@ -1126,8 +1170,15 @@ void conf_set_all_new_symbols(enum conf_def_mode mode) | |||
1126 | sym->def[S_DEF_USER].tri = no; | 1170 | sym->def[S_DEF_USER].tri = no; |
1127 | break; | 1171 | break; |
1128 | case def_random: | 1172 | case def_random: |
1129 | cnt = sym->type == S_TRISTATE ? 3 : 2; | 1173 | sym->def[S_DEF_USER].tri = no; |
1130 | sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt); | 1174 | cnt = rand() % 100; |
1175 | if (sym->type == S_TRISTATE) { | ||
1176 | if (cnt < pty) | ||
1177 | sym->def[S_DEF_USER].tri = yes; | ||
1178 | else if (cnt < (pty+ptm)) | ||
1179 | sym->def[S_DEF_USER].tri = mod; | ||
1180 | } else if (cnt < pby) | ||
1181 | sym->def[S_DEF_USER].tri = yes; | ||
1131 | break; | 1182 | break; |
1132 | default: | 1183 | default: |
1133 | continue; | 1184 | continue; |