kconfig: do not write choice values when their dependency becomes n
[carl9170fw.git] / config / symbol.c
index 20136ffefb23b814fa8b300b70a07b821b3ec71f..13f7fdfe328dc36daf8f958da879be0e665c0a67 100644 (file)
@@ -77,7 +77,7 @@ const char *sym_type_name(enum symbol_type type)
 {
        switch (type) {
        case S_BOOLEAN:
-               return "boolean";
+               return "bool";
        case S_TRISTATE:
                return "tristate";
        case S_INT:
@@ -371,11 +371,13 @@ void sym_calc_value(struct symbol *sym)
                sym->curr.tri = no;
                return;
        }
-       if (!sym_is_choice_value(sym))
-               sym->flags &= ~SYMBOL_WRITE;
+       sym->flags &= ~SYMBOL_WRITE;
 
        sym_calc_visibility(sym);
 
+       if (sym->visible != no)
+               sym->flags |= SYMBOL_WRITE;
+
        /* set default if recursively called */
        sym->curr = newval;
 
@@ -390,7 +392,6 @@ void sym_calc_value(struct symbol *sym)
                                /* if the symbol is visible use the user value
                                 * if available, otherwise try the default value
                                 */
-                               sym->flags |= SYMBOL_WRITE;
                                if (sym_has_value(sym)) {
                                        newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri,
                                                              sym->visible);
@@ -433,12 +434,9 @@ void sym_calc_value(struct symbol *sym)
        case S_STRING:
        case S_HEX:
        case S_INT:
-               if (sym->visible != no) {
-                       sym->flags |= SYMBOL_WRITE;
-                       if (sym_has_value(sym)) {
-                               newval.val = sym->def[S_DEF_USER].val;
-                               break;
-                       }
+               if (sym->visible != no && sym_has_value(sym)) {
+                       newval.val = sym->def[S_DEF_USER].val;
+                       break;
                }
                prop = sym_get_default_prop(sym);
                if (prop) {
@@ -907,6 +905,10 @@ const char *sym_expand_string_value(const char *in)
        char *res;
        size_t reslen;
 
+       /*
+        * Note: 'in' might come from a token that's about to be
+        * freed, so make sure to always allocate a new string
+        */
        reslen = strlen(in) + 1;
        res = xmalloc(reslen);
        res[0] = '\0';
@@ -1061,7 +1063,7 @@ struct symbol **sym_re_search(const char *pattern)
        }
        if (sym_match_arr) {
                qsort(sym_match_arr, cnt, sizeof(struct sym_match), sym_rel_comp);
-               sym_arr = malloc((cnt+1) * sizeof(struct symbol));
+               sym_arr = malloc((cnt+1) * sizeof(struct symbol *));
                if (!sym_arr)
                        goto sym_re_search_free;
                for (i = 0; i < cnt; i++)
@@ -1150,8 +1152,7 @@ static void sym_check_print_recursive(struct symbol *last_sym)
                if (stack->sym == last_sym)
                        fprintf(stderr, "%s:%d:error: recursive dependency detected!\n",
                                prop->file->name, prop->lineno);
-                       fprintf(stderr, "For a resolution refer to Documentation/kbuild/kconfig-language.txt\n");
-                       fprintf(stderr, "subsection \"Kconfig recursive dependency limitations\"\n");
+
                if (stack->expr) {
                        fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
                                prop->file->name, prop->lineno,
@@ -1181,6 +1182,11 @@ static void sym_check_print_recursive(struct symbol *last_sym)
                }
        }
 
+       fprintf(stderr,
+               "For a resolution refer to Documentation/kbuild/kconfig-language.txt\n"
+               "subsection \"Kconfig recursive dependency limitations\"\n"
+               "\n");
+
        if (check_top == &cv_stack)
                dep_stack_remove();
 }