Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1181364 > unrolled thread

[PATCH v3 0/2] kconfig: warn of unhandled characters in Kconfig commands

Started byAndreas Ruprecht <andreas.ruprecht@fau.de>
First post2015-07-10 10:30 +0200
Last post2015-07-11 18:00 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v3 0/2] kconfig: warn of unhandled characters in Kconfig commands Andreas Ruprecht <andreas.ruprecht@fau.de> - 2015-07-10 10:30 +0200
    [PATCH v3 1/2] kconfig: warn of unhandled characters in Kconfig commands Andreas Ruprecht <andreas.ruprecht@fau.de> - 2015-07-10 10:30 +0200
    Re: [PATCH v3 0/2] kconfig: warn of unhandled characters in Kconfig  commands Ulf Magnusson <ulfalizer.lkml@gmail.com> - 2015-07-11 18:00 +0200

#1181364 — [PATCH v3 0/2] kconfig: warn of unhandled characters in Kconfig commands

FromAndreas Ruprecht <andreas.ruprecht@fau.de>
Date2015-07-10 10:30 +0200
Subject[PATCH v3 0/2] kconfig: warn of unhandled characters in Kconfig commands
Message-ID<pKBQZ-3yi-1@gated-at.bofh.it>
This patchset changes the lexer file to emit a warning if any unhandled
characters are found in the input. So far, Kconfig options like

 +config FOO
    bool
    [...]

(note the wrong '+'!) were parsed without a warning. As simply adding a
warning for '.' produces lots of warnings as occasionally '---help---'
is used instead of 'help' (and thus '-' is recognized as an unhandled
character), we need to handle '---help---' separately.

Changes to v1:
	- add '---help---' in zconf.gperf instead of special casing
	  it in zconf.l

Changes to v2:
	- Do no constify char parameter to warn_ignored_character
	- Shorten rule definitions for '.'

Andreas Ruprecht (2):
  kconfig: warn of unhandled characters in Kconfig commands
  kconfig: Regenerate shipped zconf.{hash,lex}.c files

 scripts/kconfig/zconf.gperf          |   1 +
 scripts/kconfig/zconf.hash.c_shipped |  58 ++++---
 scripts/kconfig/zconf.l              |  20 ++-
 scripts/kconfig/zconf.lex.c_shipped  | 325 +++++++++++++++++------------------
 4 files changed, 204 insertions(+), 200 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1181366 — [PATCH v3 1/2] kconfig: warn of unhandled characters in Kconfig commands

FromAndreas Ruprecht <andreas.ruprecht@fau.de>
Date2015-07-10 10:30 +0200
Subject[PATCH v3 1/2] kconfig: warn of unhandled characters in Kconfig commands
Message-ID<pKBR0-3yi-5@gated-at.bofh.it>
In reply to#1181364
In Kconfig, definitions of options take the following form:
"<COMMAND> <PARAM> <PARAM> ...". COMMANDs and PARAMs are treated
slightly different by the underlying parser.

While commit 2e0d737fc76f ("kconfig: don't silently ignore unhandled
characters") introduced a warning for unsupported characters around
PARAMs, it does not cover situations where a COMMAND has additional
characters before it.

This change makes Kconfig emit a warning if superfluous characters
are found before COMMANDs. As the 'help' statement sometimes is
written as '---help---', the '-' character would now also be regarded
as unhandled and generate a warning. To avoid that, '-' is added to
the list of allowed characters, and the token '---help---' is included
in the zconf.gperf file.

Reported-by: Valentin Rothberg <valentinrothberg@gmail.com>
Signed-off-by: Andreas Ruprecht <andreas.ruprecht@fau.de>
---
Changes to v1:
	- add '---help---' in zconf.gperf instead of special casing
	  it in zconf.l

Changes to v2:
	- Do no constify char parameter to warn_ignored_character
	- Shorten rule definitions for '.'

 scripts/kconfig/zconf.gperf |  1 +
 scripts/kconfig/zconf.l     | 20 +++++++++++---------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/scripts/kconfig/zconf.gperf b/scripts/kconfig/zconf.gperf
index b6ac02d..7aceb7b 100644
--- a/scripts/kconfig/zconf.gperf
+++ b/scripts/kconfig/zconf.gperf
@@ -22,6 +22,7 @@ comment,	T_COMMENT,	TF_COMMAND
 config,		T_CONFIG,	TF_COMMAND
 menuconfig,	T_MENUCONFIG,	TF_COMMAND
 help,		T_HELP,		TF_COMMAND
+"---help---",   T_HELP,     TF_COMMAND
 if,		T_IF,		TF_COMMAND|TF_PARAM
 endif,		T_ENDIF,	TF_COMMAND
 depends,	T_DEPENDS,	TF_COMMAND
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index 200a3fe..c410d25 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -66,9 +66,16 @@ static void alloc_string(const char *str, int size)
 	memcpy(text, str, size);
 	text[size] = 0;
 }
+
+static void warn_ignored_character(char chr)
+{
+	fprintf(stderr,
+	        "%s:%d:warning: ignoring unsupported character '%c'\n",
+	        zconf_curname(), zconf_lineno(), chr);
+}
 %}
 
-n	[A-Za-z0-9_]
+n	[A-Za-z0-9_-]
 
 %%
 	int str = 0;
@@ -106,7 +113,7 @@ n	[A-Za-z0-9_]
 		zconflval.string = text;
 		return T_WORD;
 	}
-	.
+	.	warn_ignored_character(*yytext);
 	\n	{
 		BEGIN(INITIAL);
 		current_file->lineno++;
@@ -132,8 +139,7 @@ n	[A-Za-z0-9_]
 		BEGIN(STRING);
 	}
 	\n	BEGIN(INITIAL); current_file->lineno++; return T_EOL;
-	---	/* ignore */
-	({n}|[-/.])+	{
+	({n}|[/.])+	{
 		const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
 		if (id && id->flags & TF_PARAM) {
 			zconflval.id = id;
@@ -146,11 +152,7 @@ n	[A-Za-z0-9_]
 	#.*	/* comment */
 	\\\n	current_file->lineno++;
 	[[:blank:]]+
-	.	{
-		fprintf(stderr,
-		        "%s:%d:warning: ignoring unsupported character '%c'\n",
-		        zconf_curname(), zconf_lineno(), *yytext);
-	}
+	.	warn_ignored_character(*yytext);
 	<<EOF>> {
 		BEGIN(INITIAL);
 	}
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1182183 — Re: [PATCH v3 0/2] kconfig: warn of unhandled characters in Kconfig commands

FromUlf Magnusson <ulfalizer.lkml@gmail.com>
Date2015-07-11 18:00 +0200
SubjectRe: [PATCH v3 0/2] kconfig: warn of unhandled characters in Kconfig commands
Message-ID<pL5m3-4Xo-37@gated-at.bofh.it>
In reply to#1181364
On Fri, Jul 10, 2015 at 10:25:31AM +0200, Andreas Ruprecht wrote:
> This patchset changes the lexer file to emit a warning if any unhandled
> characters are found in the input. So far, Kconfig options like
> 
>  +config FOO
>     bool
>     [...]
> 
> (note the wrong '+'!) were parsed without a warning. As simply adding a
> warning for '.' produces lots of warnings as occasionally '---help---'
> is used instead of 'help' (and thus '-' is recognized as an unhandled
> character), we need to handle '---help---' separately.
> 
> Changes to v1:
> 	- add '---help---' in zconf.gperf instead of special casing
> 	  it in zconf.l
> 
> Changes to v2:
> 	- Do no constify char parameter to warn_ignored_character
> 	- Shorten rule definitions for '.'
> 
> Andreas Ruprecht (2):
>   kconfig: warn of unhandled characters in Kconfig commands
>   kconfig: Regenerate shipped zconf.{hash,lex}.c files
> 
>  scripts/kconfig/zconf.gperf          |   1 +
>  scripts/kconfig/zconf.hash.c_shipped |  58 ++++---
>  scripts/kconfig/zconf.l              |  20 ++-
>  scripts/kconfig/zconf.lex.c_shipped  | 325 +++++++++++++++++------------------
>  4 files changed, 204 insertions(+), 200 deletions(-)
> 
> -- 
> 1.9.1
> 

Looks good to me.

I ran the Kconfiglib test suite on it too. Since it simply compares the
output of Kconfiglib and the C implementation, it doubles as a good
regression test for the C implementation.

Cheers,
Ulf
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web