Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758679AbbGHUOk (ORCPT ); Wed, 8 Jul 2015 16:14:40 -0400 Received: from mail-ob0-f174.google.com ([209.85.214.174]:34621 "EHLO mail-ob0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755061AbbGHUOc (ORCPT ); Wed, 8 Jul 2015 16:14:32 -0400 MIME-Version: 1.0 In-Reply-To: <5a5844d23d18500aacbed671fd0c77019f5e32bd.1436264921.git.andreas.ruprecht@fau.de> References: <5a5844d23d18500aacbed671fd0c77019f5e32bd.1436264921.git.andreas.ruprecht@fau.de> Date: Wed, 8 Jul 2015 22:14:31 +0200 Message-ID: Subject: Re: [PATCH v2 1/2] kconfig: warn of unhandled characters in Kconfig commands From: Ulf Magnusson To: Andreas Ruprecht Cc: Paul Bolle , Valentin Rothberg , rafael.j.wysocki@intel.com, "open list:KCONFIG" , Kernel Mailing List , hengelein Stefan , linux@dominikbrodowski.net, Michal Marek Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3906 Lines: 107 On Tue, Jul 7, 2015 at 12:31 PM, Andreas Ruprecht wrote: > In Kconfig, definitions of options take the following form: > " ...". 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 around it. > > This change makes Kconfig emit a warning if superfluous characters > are found around 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 > Signed-off-by: Andreas Ruprecht > --- > scripts/kconfig/zconf.gperf | 1 + > scripts/kconfig/zconf.l | 18 ++++++++++++------ > 2 files changed, 13 insertions(+), 6 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..3078244 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(const char chr) > +{ > + fprintf(stderr, > + "%s:%d:warning: ignoring unsupported character '%c'\n", > + zconf_curname(), zconf_lineno(), chr); > +} Was the 'const' on the non-pointer 'chr' parameter intended here? > %} > > -n [A-Za-z0-9_] > +n [A-Za-z0-9_-] > > %% > int str = 0; > @@ -106,7 +113,9 @@ n [A-Za-z0-9_] > zconflval.string = text; > return T_WORD; > } > - . > + . { > + warn_ignored_character(*yytext); > + } > \n { > BEGIN(INITIAL); > current_file->lineno++; > @@ -132,7 +141,6 @@ n [A-Za-z0-9_] > BEGIN(STRING); > } > \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; > - --- /* ignore */ > ({n}|[-/.])+ { Removing '-' from [-/.] too works fine on my system (Flex 2.5.39, Bison 3.0.2, as shipped with Ubuntu 15.04). What problems did you run into? > const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); > if (id && id->flags & TF_PARAM) { > @@ -147,9 +155,7 @@ n [A-Za-z0-9_] > \\\n current_file->lineno++; > [[:blank:]]+ > . { > - fprintf(stderr, > - "%s:%d:warning: ignoring unsupported character '%c'\n", > - zconf_curname(), zconf_lineno(), *yytext); > + warn_ignored_character(*yytext); > } > <> { > BEGIN(INITIAL); > -- > 1.9.1 > 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/