kconfig: add more S_INT and S_HEX consistency checks
authorArnaud Lacombe <lacombar@gmail.com>
Sun, 5 Dec 2010 06:29:25 +0000 (01:29 -0500)
committerMichal Marek <mmarek@suse.cz>
Wed, 15 Dec 2010 22:15:32 +0000 (23:15 +0100)
This patch add more number consistency checkg, trying to catch the following
situation:

config FOO0
hex
default 42

config FOO1
string

config BAR0
int
default FOO1

config BAR1
hex
default FOO1

config FOO2
hex
default 42h

config FOO3
int
default "1bar"

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
scripts/kconfig/menu.c

index 7e83aef42c6d41c63051664b2669c922356bff3a..8a8bc9be783160c62bc71572ab98de0ccf1f563d 100644 (file)
@@ -183,7 +183,7 @@ void menu_add_option(int token, char *arg)
        }
 }
 
-static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2)
+static int menu_validate_number(struct symbol *sym, struct symbol *sym2)
 {
        return sym2->type == S_INT || sym2->type == S_HEX ||
               (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name));
@@ -201,6 +201,15 @@ static void sym_check_prop(struct symbol *sym)
                                prop_warn(prop,
                                    "default for config symbol '%s'"
                                    " must be a single symbol", sym->name);
+                       if (prop->expr->type != E_SYMBOL)
+                               break;
+                       sym2 = prop_get_symbol(prop);
+                       if (sym->type == S_HEX || sym->type == S_INT) {
+                               if (!menu_validate_number(sym, sym2))
+                                       prop_warn(prop,
+                                           "'%s': number is invalid",
+                                           sym->name);
+                       }
                        break;
                case P_SELECT:
                        sym2 = prop_get_symbol(prop);
@@ -220,8 +229,8 @@ static void sym_check_prop(struct symbol *sym)
                        if (sym->type != S_INT && sym->type != S_HEX)
                                prop_warn(prop, "range is only allowed "
                                                "for int or hex symbols");
-                       if (!menu_range_valid_sym(sym, prop->expr->left.sym) ||
-                           !menu_range_valid_sym(sym, prop->expr->right.sym))
+                       if (!menu_validate_number(sym, prop->expr->left.sym) ||
+                           !menu_validate_number(sym, prop->expr->right.sym))
                                prop_warn(prop, "range is invalid");
                        break;
                default: