]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - scripts/kconfig/conf.c
kconfig: improve seed in randconfig
[linux-2.6-omap-h63xx.git] / scripts / kconfig / conf.c
index 3e1057f885c6a2496e981e6180611aa6878cede0..d190092c3b6ebf00d09a68fa4e5cb606afacd364 100644 (file)
@@ -11,6 +11,7 @@
 #include <time.h>
 #include <unistd.h>
 #include <sys/stat.h>
+#include <sys/time.h>
 
 #define LKC_DIRECT_LINK
 #include "lkc.h"
@@ -464,9 +465,22 @@ int main(int ac, char **av)
                        input_mode = set_yes;
                        break;
                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;
-                       srand(time(NULL));
                        break;
+               }
                case 'h':
                        printf(_("See README for usage info\n"));
                        exit(0);