Commit 59fcbdda authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-fixes

* git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-fixes:
  kconfig: improve seed in randconfig
  kconfig: fix randconfig for choice blocks
parents 39678e5e b0fe5510
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/time.h>
#define LKC_DIRECT_LINK #define LKC_DIRECT_LINK
#include "lkc.h" #include "lkc.h"
...@@ -464,9 +465,22 @@ int main(int ac, char **av) ...@@ -464,9 +465,22 @@ int main(int ac, char **av)
input_mode = set_yes; input_mode = set_yes;
break; break;
case 'r': case 'r':
{
struct timeval now;
unsigned int seed;
/*
* Use microseconds derived seed,
* compensate for systems where it may be zero
*/
gettimeofday(&now, NULL);
seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));
srand(seed);
input_mode = set_random; input_mode = set_random;
srand(time(NULL));
break; break;
}
case 'h': case 'h':
printf(_("See README for usage info\n")); printf(_("See README for usage info\n"));
exit(0); exit(0);
......
...@@ -843,7 +843,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode) ...@@ -843,7 +843,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
default: default:
continue; continue;
} }
if (!sym_is_choice(sym) || mode != def_random) if (!(sym_is_choice(sym) && mode == def_random))
sym->flags |= SYMBOL_DEF_USER; sym->flags |= SYMBOL_DEF_USER;
break; break;
default: default:
...@@ -856,28 +856,49 @@ void conf_set_all_new_symbols(enum conf_def_mode mode) ...@@ -856,28 +856,49 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
if (mode != def_random) if (mode != def_random)
return; return;
/*
* We have different type of choice blocks.
* If curr.tri equal to mod then we can select several
* choice symbols in one block.
* In this case we do nothing.
* If curr.tri equal yes then only one symbol can be
* selected in a choice block and we set it to yes,
* and the rest to no.
*/
for_all_symbols(i, csym) { for_all_symbols(i, csym) {
if (sym_has_value(csym) || !sym_is_choice(csym)) if (sym_has_value(csym) || !sym_is_choice(csym))
continue; continue;
sym_calc_value(csym); sym_calc_value(csym);
if (csym->curr.tri != yes)
continue;
prop = sym_get_choice_prop(csym); prop = sym_get_choice_prop(csym);
def = -1;
while (1) { /* count entries in choice block */
cnt = 0;
expr_list_for_each_sym(prop->expr, e, sym)
cnt++;
/*
* find a random value and set it to yes,
* set the rest to no so we have only one set
*/
def = (rand() % cnt);
cnt = 0; cnt = 0;
expr_list_for_each_sym(prop->expr, e, sym) { expr_list_for_each_sym(prop->expr, e, sym) {
if (sym->visible == no)
continue;
if (def == cnt++) { if (def == cnt++) {
sym->def[S_DEF_USER].tri = yes;
csym->def[S_DEF_USER].val = sym; csym->def[S_DEF_USER].val = sym;
break;
} }
else {
sym->def[S_DEF_USER].tri = no;
} }
if (def >= 0 || cnt < 2)
break;
def = (rand() % cnt) + 1;
} }
csym->flags |= SYMBOL_DEF_USER; csym->flags |= SYMBOL_DEF_USER;
/* clear VALID to get value calculated */
csym->flags &= ~(SYMBOL_VALID);
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment