kconfig: hide irrelevant sub-menus for oldconfig
[carl9170fw.git] / config / symbol.c
index 3c8bd9bb4267a874cd1fa112d4a21b569bd56296..0f7eba7d472a6a762e154bbcfede05b0ef8044db 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:
@@ -183,7 +183,7 @@ static void sym_validate_range(struct symbol *sym)
                sprintf(str, "%lld", val2);
        else
                sprintf(str, "0x%llx", val2);
-       sym->curr.val = strdup(str);
+       sym->curr.val = xstrdup(str);
 }
 
 static void sym_set_changed(struct symbol *sym)
@@ -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);
@@ -402,9 +403,10 @@ void sym_calc_value(struct symbol *sym)
                        if (!sym_is_choice(sym)) {
                                prop = sym_get_default_prop(sym);
                                if (prop) {
-                                       sym->flags |= SYMBOL_WRITE;
                                        newval.tri = EXPR_AND(expr_calc_value(prop->expr),
                                                              prop->visible.tri);
+                                       if (newval.tri != no)
+                                               sym->flags |= SYMBOL_WRITE;
                                }
                                if (sym->implied.tri != no) {
                                        sym->flags |= SYMBOL_WRITE;
@@ -433,12 +435,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) {
@@ -851,7 +850,7 @@ struct symbol *sym_lookup(const char *name, int flags)
                                   : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE))))
                                return symbol;
                }
-               new_name = strdup(name);
+               new_name = xstrdup(name);
        } else {
                new_name = NULL;
                hash = 0;
@@ -901,12 +900,16 @@ struct symbol *sym_find(const char *name)
  * name to be expanded shall be prefixed by a '$'. Unknown symbol expands to
  * the empty string.
  */
-const char *sym_expand_string_value(const char *in)
+char *sym_expand_string_value(const char *in)
 {
        const char *src;
        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';
@@ -934,7 +937,7 @@ const char *sym_expand_string_value(const char *in)
                newlen = strlen(res) + strlen(symval) + strlen(src) + 1;
                if (newlen > reslen) {
                        reslen = newlen;
-                       res = realloc(res, reslen);
+                       res = xrealloc(res, reslen);
                }
 
                strcat(res, symval);
@@ -1150,8 +1153,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 +1183,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();
 }
@@ -1215,7 +1222,7 @@ static struct symbol *sym_check_expr_deps(struct expr *e)
        default:
                break;
        }
-       printf("Oops! How to check %d?\n", e->type);
+       fprintf(stderr, "Oops! How to check %d?\n", e->type);
        return NULL;
 }