kconfig: Avoid format overflow warning from GCC 8.1
[carl9170fw.git] / config / util.c
index 138894ef49ea18545468de9b1021c58505d36454..a365594770d9daaaaf3220c80eb1522113930072 100644 (file)
 struct file *file_lookup(const char *name)
 {
        struct file *file;
-       const char *file_name = sym_expand_string_value(name);
 
        for (file = file_list; file; file = file->next) {
                if (!strcmp(name, file->name)) {
-                       free((void *)file_name);
                        return file;
                }
        }
 
        file = xmalloc(sizeof(*file));
        memset(file, 0, sizeof(*file));
-       file->name = file_name;
+       file->name = xstrdup(name);
        file->next = file_list;
        file_list = file;
        return file;
@@ -34,8 +32,6 @@ struct file *file_lookup(const char *name)
 /* write a dependency file as used by kbuild to track dependencies */
 int file_write_dep(const char *name)
 {
-       struct symbol *sym, *env_sym;
-       struct expr *e;
        struct file *file;
        FILE *out;
 
@@ -54,21 +50,7 @@ int file_write_dep(const char *name)
        fprintf(out, "\n%s: \\\n"
                     "\t$(deps_config)\n\n", conf_get_autoconfig_name());
 
-       expr_list_for_each_sym(sym_env_list, e, sym) {
-               struct property *prop;
-               const char *value;
-
-               prop = sym_get_env_prop(sym);
-               env_sym = prop_get_symbol(prop);
-               if (!env_sym)
-                       continue;
-               value = getenv(env_sym->name);
-               if (!value)
-                       value = "";
-               fprintf(out, "ifneq \"$(%s)\" \"%s\"\n", env_sym->name, value);
-               fprintf(out, "%s: FORCE\n", conf_get_autoconfig_name());
-               fprintf(out, "endif\n");
-       }
+       env_write_dep(out, conf_get_autoconfig_name());
 
        fprintf(out, "\n$(deps_config): ;\n");
        fclose(out);
@@ -154,3 +136,25 @@ void *xrealloc(void *p, size_t size)
        fprintf(stderr, "Out of memory.\n");
        exit(1);
 }
+
+char *xstrdup(const char *s)
+{
+       char *p;
+
+       p = strdup(s);
+       if (p)
+               return p;
+       fprintf(stderr, "Out of memory.\n");
+       exit(1);
+}
+
+char *xstrndup(const char *s, size_t n)
+{
+       char *p;
+
+       p = strndup(s, n);
+       if (p)
+               return p;
+       fprintf(stderr, "Out of memory.\n");
+       exit(1);
+}