kconfig: Add error handling to KCONFIG_ALLCONFIG
authorEric W. Biederman <ebiederm@xmission.com>
Thu, 26 Apr 2012 08:51:32 +0000 (01:51 -0700)
committerChristian Lamparter <chunkeey@googlemail.com>
Sat, 21 Jul 2012 13:55:13 +0000 (15:55 +0200)
- Only try to read the file specified if KCONFIG_ALL_CONFIG is set to
  something other than the empty string or "1".

- Don't use stat to check the name passed to conf_read_simple so that
  zconf_fopen can find the file in the current directory or in SRCTREE
  removing a extremely source of confusing failure, where KCONFIG_ALL_CONFIG
  was not interpreted with respect to the directory make was called in.

- If conf_read_simple fails complain clearly and stop processing.
  Allowing the simple debugging of typos.

- Clearly document the behavior so it is clear to users which
  values are treated as flags and which values are treated as
  filenames.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
config/conf.c

index 6fdacb31a51ac712f196c397b753f45a1efd66de..b8ba1d3e53b578e5fc4e62f27d6d51063077b923 100644 (file)
@@ -552,8 +552,13 @@ int main(int ac, char **av)
        case alldefconfig:
        case randconfig:
                name = getenv("KCONFIG_ALLCONFIG");
-               if (name && !stat(name, &tmpstat)) {
-                       conf_read_simple(name, S_DEF_USER);
+               if (name && (strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) {
+                       if (conf_read_simple(name, S_DEF_USER)) {
+                               fprintf(stderr,
+                                       _("*** Can't read seed configuration \"%s\"!\n"),
+                                       name);
+                               exit(1);
+                       }
                        break;
                }
                switch (input_mode) {
@@ -564,10 +569,13 @@ int main(int ac, char **av)
                case randconfig:        name = "allrandom.config"; break;
                default: break;
                }
-               if (!stat(name, &tmpstat))
-                       conf_read_simple(name, S_DEF_USER);
-               else if (!stat("all.config", &tmpstat))
-                       conf_read_simple("all.config", S_DEF_USER);
+               if (conf_read_simple(name, S_DEF_USER) &&
+                   conf_read_simple("all.config", S_DEF_USER)) {
+                       fprintf(stderr,
+                               _("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"),
+                               name);
+                       exit(1);
+               }
                break;
        default:
                break;