smatch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Levon <levon@movementarian.org>
To: smatch@vger.kernel.org
Cc: John Levon <levon@movementarian.org>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 01/12] sparse: correctly handle "-D foo" and "-U foo"
Date: Tue, 27 Nov 2018 10:53:16 +0000	[thread overview]
Message-ID: <1543316007-25992-1-git-send-email-levon@movementarian.org> (raw)

The former fix is from sparse upstream, the -U change is by me.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: John Levon <levon@movementarian.org>
---
 lib.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/lib.c b/lib.c
index b03229c..0f7ad2a 100644
--- a/lib.c
+++ b/lib.c
@@ -325,15 +325,19 @@ static char **handle_switch_D(char *arg, char **next)
 	const char *name = arg + 1;
 	const char *value = "1";
 
-	if (!*name || isspace((unsigned char)*name))
-		die("argument to `-D' is missing");
+	if (!*name) {
+		arg = *++next;
+		if (!arg)
+			die("argument to `-D' is missing");
+		name = arg;
+	}
 
-	for (;;) {
+	for (;;arg++) {
 		char c;
-		c = *++arg;
+		c = *arg;
 		if (!c)
 			break;
-		if (isspace((unsigned char)c) || c == '=') {
+		if (c == '=') {
 			*arg = '\0';
 			value = arg + 1;
 			break;
@@ -680,6 +684,8 @@ static void handle_switch_v_finalize(void)
 static char **handle_switch_U(char *arg, char **next)
 {
 	const char *name = arg + 1;
+	if (*name == '\0')
+		name = *++next;
 	add_pre_buffer ("#undef %s\n", name);
 	return next;
 }
-- 
1.8.3.1

             reply	other threads:[~2018-11-27 21:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-27 10:53 John Levon [this message]
2018-11-27 10:53 ` [PATCH 02/12] sparse: add -Wno-non-ansi-function-declaration John Levon
2018-11-27 10:53 ` [PATCH 03/12] sparse: add -Wbig-constants John Levon
2018-11-27 10:53 ` [PATCH 04/12] sparse: add -Wempty-character-constant John Levon
2018-11-27 10:53 ` [PATCH 05/12] Look across the entire compile line for smatch arguments John Levon
2018-11-27 10:53 ` [PATCH 06/12] Regularise error reporting John Levon
2018-11-27 10:53 ` [PATCH 07/12] Convert all sm_msg("warn:.." into sm_warning() John Levon
2018-11-27 10:53 ` [PATCH 08/12] Convert sm_msg() with an error: prefix into sm_error() John Levon
2018-11-27 10:53 ` [PATCH 09/12] Convert some sm_msg() into more specific reporting routines John Levon
2018-11-27 10:53 ` [PATCH 10/12] Track sparse-level warnings and errors too, and respect them in smatch's exit code John Levon
2018-11-27 10:53 ` [PATCH 11/12] Add illumos projects John Levon
2018-11-27 10:53 ` [PATCH 12/12] Add check_all_func_returns John Levon

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=1543316007-25992-1-git-send-email-levon@movementarian.org \
    --to=levon@movementarian.org \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=smatch@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).