public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
To: linux-kbuild@vger.kernel.org, yann.morin.1998@free.fr
Cc: alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Subject: [PATCH] kconfig: improve handling EOF
Date: Fri, 19 Dec 2014 17:20:30 +0200	[thread overview]
Message-ID: <1419002430-164635-1-git-send-email-kirill.shutemov@linux.intel.com> (raw)

The patch fixes two EOF-related issues in kconfig lexer:

1. End of file is not valid end of string token. Currently we happily
   accept something like

	config FOO
		bool "Bar

   If there's EOF just after '"Bar' without newline.

2. Kconfig produces obscure error message if we miss newline at the end
   of file. Testcase:

	% echo -n 'if FOO\nendif' >> drivers/Kconfig
	% make allmodconfig
	...
	drivers/Kconfig:191: 'endif' in different file than 'if'
	drivers/Kconfig:191: location of the 'if'
	scripts/kconfig/Makefile:80: recipe for target 'allmodconfig' failed
	make[1]: *** [allmodconfig] Error 1
	Makefile:558: recipe for target 'allmodconfig' failed
	make: *** [allmodconfig] Error 2

   We can fix it if forbid EOF form <PARAM> context.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
 kernel/Kconfig.preempt  | 2 +-
 scripts/kconfig/zconf.l | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt
index 3f9c97419f02..037284c5f723 100644
--- a/kernel/Kconfig.preempt
+++ b/kernel/Kconfig.preempt
@@ -55,4 +55,4 @@ config PREEMPT
 endchoice
 
 config PREEMPT_COUNT
-       bool
\ No newline at end of file
+       bool
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index 6c62d93b4ffb..001abe8df6ce 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -143,7 +143,9 @@ n	[A-Za-z0-9_]
 	\\\n	current_file->lineno++;
 	.
 	<<EOF>> {
-		BEGIN(INITIAL);
+		printf("%s:%d: no newline at end of file\n",
+				zconf_curname(), zconf_lineno());
+		exit(1);
 	}
 }
 
@@ -179,7 +181,9 @@ n	[A-Za-z0-9_]
 		return T_EOL;
 	}
 	<<EOF>>	{
-		BEGIN(INITIAL);
+		printf("%s:%d: unexpected end of file\n",
+				zconf_curname(), zconf_lineno());
+		exit(1);
 	}
 }
 
-- 
2.1.3


             reply	other threads:[~2014-12-19 15:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-19 15:20 Kirill A. Shutemov [this message]
2014-12-19 17:07 ` [PATCH] kconfig: improve handling EOF Paul Bolle

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=1419002430-164635-1-git-send-email-kirill.shutemov@linux.intel.com \
    --to=kirill.shutemov@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yann.morin.1998@free.fr \
    /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