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(-)
@@ -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