From: Christopher Li <sparse@chrisli.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Josh Triplett <josh@joshtriplett.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Linux-Sparse <linux-sparse@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] lib.c: skip --param parameters
Date: Sun, 29 Jun 2014 00:19:10 -0700 [thread overview]
Message-ID: <CANeU7Q=FUTd4XTrQeeFGaSqp7eriZS3egAOqDK--OC-kaWyZuw@mail.gmail.com> (raw)
In-Reply-To: <CANeU7QnLad1f4KkLpTGSWB8eD8_La-tACim6rR7DLQ=hggwhOQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 509 bytes --]
Hi Andy,
On Sat, Jun 28, 2014 at 9:59 AM, Christopher Li <sparse@chrisli.org> wrote:
> I think this is problematic.There are three possible input
> from args:
> 1) "--parm", you need to ++next skip to next arg, which is the value for parm.
> 2) "--parm=x", you don't need to skip to next arg.
> 3) "--parm-with-crap", invalid argument. You don't need to skip next arg.
How about this patch, I modify from your patch.
It fix the problem I mention earlier.
If no objections, I will push the change.
Chris
[-- Attachment #2: 0001-lib.c-skip-param-parameters.patch --]
[-- Type: text/x-patch, Size: 1705 bytes --]
From d917662d54ba68d0c3b03e994cb1fa66d7b19c30 Mon Sep 17 00:00:00 2001
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Tue, 17 Jun 2014 12:11:45 +0300
Subject: [PATCH] lib.c: skip --param parameters
Very dumb patch to just skip --param allow-store-data-races=0 introduced in
newer GCC versions.
Without this patch sparse recognizes parameter of the --param option as a file
name which obviously couldn't be found.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
---
lib.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/lib.c b/lib.c
index 844797d..0bc4b2b 100644
--- a/lib.c
+++ b/lib.c
@@ -675,22 +675,42 @@ static char **handle_version(char *arg, char **next)
exit(0);
}
+static char **handle_param(char *arg, char **next)
+{
+ char *value = NULL;
+
+ /* For now just skip any '--param=*' or '--param *' */
+ if (*arg == '\0') {
+ value = *++next;
+ } else if (isspace(*arg) || *arg == '=') {
+ value = ++arg;
+ }
+
+ if (!value)
+ die("missing argument for --param option");
+
+ return next;
+}
+
struct switches {
const char *name;
char **(*fn)(char *, char **);
+ unsigned int prefix:1;
};
static char **handle_long_options(char *arg, char **next)
{
static struct switches cmd[] = {
+ { "param", handle_param, 1 },
{ "version", handle_version },
{ NULL, NULL }
};
struct switches *s = cmd;
while (s->name) {
- if (!strcmp(s->name, arg))
- return s->fn(arg, next);
+ int optlen = strlen(s->name);
+ if (!strncmp(s->name, arg, optlen + !s->prefix))
+ return s->fn(arg + optlen, next);
s++;
}
return next;
--
1.9.3
next prev parent reply other threads:[~2014-06-29 7:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-17 9:11 [PATCH v2 0/2] fix for --param GCC's command line option Andy Shevchenko
2014-06-17 9:11 ` [PATCH v2 1/2] lib.c: introduce split_value_from_arg helper Andy Shevchenko
2014-06-17 9:11 ` [PATCH v2 2/2] lib.c: skip --param parameters Andy Shevchenko
2014-06-28 16:23 ` Christopher Li
2014-06-28 16:59 ` Christopher Li
2014-06-29 7:19 ` Christopher Li [this message]
2014-06-29 19:01 ` Christopher Li
2014-06-30 8:32 ` Andy Shevchenko
2014-06-30 8:51 ` Christopher Li
2014-06-30 8:56 ` Andy Shevchenko
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='CANeU7Q=FUTd4XTrQeeFGaSqp7eriZS3egAOqDK--OC-kaWyZuw@mail.gmail.com' \
--to=sparse@chrisli.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sparse@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 NNTP newsgroup(s).