public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaud Lacombe <lacombar@gmail.com>
To: linux-kbuild@vger.kernel.org
Cc: Arnaud Lacombe <lacombar@gmail.com>
Subject: [PATCH 2/5] kconfig: add more S_INT and S_HEX consistency checks
Date: Sun,  5 Dec 2010 01:29:25 -0500	[thread overview]
Message-ID: <1291530566-23531-2-git-send-email-lacombar@gmail.com> (raw)
In-Reply-To: <1291530566-23531-1-git-send-email-lacombar@gmail.com>

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>
---
 scripts/kconfig/menu.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 7e83aef..8a8bc9b 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -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:
-- 
1.7.2.30.gc37d7.dirty


  reply	other threads:[~2010-12-05  6:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-05  6:29 [PATCH 1/5] kconfig: make hexadecimal prefix mandatory for S_HEX default value Arnaud Lacombe
2010-12-05  6:29 ` Arnaud Lacombe [this message]
2010-12-15  6:20   ` [PATCH 2/5] kconfig: add more S_INT and S_HEX consistency checks Arnaud Lacombe
2010-12-15 22:47   ` Michal Marek
2010-12-05  6:29 ` [PATCH 3/5 to 5/5] Add missing hexadicimal prefix Arnaud Lacombe
2010-12-15  6:22 ` [PATCH 1/5] kconfig: make hexadecimal prefix mandatory for S_HEX default value Arnaud Lacombe
2010-12-15 22:49 ` Michal Marek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1291530566-23531-2-git-send-email-lacombar@gmail.com \
    --to=lacombar@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox