···1111#include <time.h>1212#include <unistd.h>1313#include <sys/stat.h>1414+#include <sys/time.h>14151516#define LKC_DIRECT_LINK1617#include "lkc.h"···465464 input_mode = set_yes;466465 break;467466 case 'r':467467+ {468468+ struct timeval now;469469+ unsigned int seed;470470+471471+ /*472472+ * Use microseconds derived seed,473473+ * compensate for systems where it may be zero474474+ */475475+ gettimeofday(&now, NULL);476476+477477+ seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));478478+ srand(seed);479479+468480 input_mode = set_random;469469- srand(time(NULL));470481 break;482482+ }471483 case 'h':472484 printf(_("See README for usage info\n"));473485 exit(0);
+36-15
scripts/kconfig/confdata.c
···843843 default:844844 continue;845845 }846846- if (!sym_is_choice(sym) || mode != def_random)846846+ if (!(sym_is_choice(sym) && mode == def_random))847847 sym->flags |= SYMBOL_DEF_USER;848848 break;849849 default:···856856857857 if (mode != def_random)858858 return;859859-859859+ /*860860+ * We have different type of choice blocks.861861+ * If curr.tri equal to mod then we can select several862862+ * choice symbols in one block.863863+ * In this case we do nothing.864864+ * If curr.tri equal yes then only one symbol can be865865+ * selected in a choice block and we set it to yes,866866+ * and the rest to no.867867+ */860868 for_all_symbols(i, csym) {861869 if (sym_has_value(csym) || !sym_is_choice(csym))862870 continue;863871864872 sym_calc_value(csym);873873+874874+ if (csym->curr.tri != yes)875875+ continue;876876+865877 prop = sym_get_choice_prop(csym);866866- def = -1;867867- while (1) {868868- cnt = 0;869869- expr_list_for_each_sym(prop->expr, e, sym) {870870- if (sym->visible == no)871871- continue;872872- if (def == cnt++) {873873- csym->def[S_DEF_USER].val = sym;874874- break;875875- }878878+879879+ /* count entries in choice block */880880+ cnt = 0;881881+ expr_list_for_each_sym(prop->expr, e, sym)882882+ cnt++;883883+884884+ /*885885+ * find a random value and set it to yes,886886+ * set the rest to no so we have only one set887887+ */888888+ def = (rand() % cnt);889889+890890+ cnt = 0;891891+ expr_list_for_each_sym(prop->expr, e, sym) {892892+ if (def == cnt++) {893893+ sym->def[S_DEF_USER].tri = yes;894894+ csym->def[S_DEF_USER].val = sym;876895 }877877- if (def >= 0 || cnt < 2)878878- break;879879- def = (rand() % cnt) + 1;896896+ else {897897+ sym->def[S_DEF_USER].tri = no;898898+ }880899 }881900 csym->flags |= SYMBOL_DEF_USER;901901+ /* clear VALID to get value calculated */902902+ csym->flags &= ~(SYMBOL_VALID);882903 }883904}