uml: fix build with gcc 5
[lede.git] / scripts / config / conf.c
index 1f94816cf209e357ef3347a0bce8158798d978bb..16e5c4378718c37f2e9ad14f97673c74ed00b4c6 100644 (file)
@@ -13,6 +13,7 @@
 #include <getopt.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+#include <errno.h>
 
 #include "lkc.h"
 
@@ -502,7 +503,6 @@ int main(int ac, char **av)
        tty_stdio = isatty(0) && isatty(1) && isatty(2);
 
        while ((opt = getopt_long(ac, av, "r:w:", long_opts, NULL)) != -1) {
-               input_mode = (enum input_mode)opt;
                switch (opt) {
                case silentoldconfig:
                        sync_kconfig = 1;
@@ -515,14 +515,24 @@ int main(int ac, char **av)
                {
                        struct timeval now;
                        unsigned int seed;
+                       char *seed_env;
 
                        /*
                         * 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));
+
+                       seed_env = getenv("KCONFIG_SEED");
+                       if( seed_env && *seed_env ) {
+                               char *endp;
+                               int tmp = (int)strtol(seed_env, &endp, 0);
+                               if (*endp == '\0') {
+                                       seed = tmp;
+                               }
+                       }
+                       fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed );
                        srand(seed);
                        break;
                }
@@ -537,15 +547,16 @@ int main(int ac, char **av)
                        break;
                case 'r':
                        input_file = optarg;
-                       break;
+                       continue;
                case 'w':
                        output_file = optarg;
-                       break;
+                       continue;
                case '?':
                        conf_usage(progname);
                        exit(1);
                        break;
                }
+               input_mode = (enum input_mode)opt;
        }
        if (ac == optind) {
                printf(_("%s: Kconfig file missing\n"), av[0]);
@@ -622,7 +633,8 @@ int main(int ac, char **av)
                conf_set_all_new_symbols(def_default);
                break;
        case randconfig:
-               conf_set_all_new_symbols(def_random);
+               /* Really nothing to do in this loop */
+               while (conf_set_all_new_symbols(def_random)) ;
                break;
        case defconfig:
                conf_set_all_new_symbols(def_default);
@@ -664,7 +676,7 @@ int main(int ac, char **av)
        } else if (input_mode == savedefconfig) {
                if (conf_write_defconfig(defconfig_file)) {
                        fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"),
-                               defconfig_file);
+                               defconfig_file);
                        return 1;
                }
        } else if (input_mode != listnewconfig) {