From: John Levon <levon@movementarian.org>
Subject: [PATCH 16/18] Look across the entire compile line for smatch arguments. This makes smatch arguments much easier to provide in Makefiles, and sparse itself doesn't overlap.
Date: Fri, 23 Nov 2018 12:17:16 +0000 [thread overview]
Message-ID: <E1gQCRX-00068m-92@movementarian.org> (raw)
Signed-off-by: John Levon <levon@movementarian.org>
---
smatch.c | 80 ++++++++++++++++++++++++----------------------------------------
1 file changed, 30 insertions(+), 50 deletions(-)
diff --git a/smatch.c b/smatch.c
index c8a6b4e3..062ef630 100644
--- a/smatch.c
+++ b/smatch.c
@@ -170,65 +170,49 @@ static int match_option(const char *arg, const char *option)
}
#define OPTION(_x) do { \
- if (!found && match_option((*argvp)[1], #_x)) { \
- found = 1; \
- option_##_x = 1; \
- (*argvp)[1] = (*argvp)[0]; \
+ if (match_option((*argvp)[1], #_x)) { \
+ option_##_x = 1; \
} \
} while (0)
void parse_args(int *argcp, char ***argvp)
{
- while (*argcp >= 2) {
- int found = 0;
- if (!strcmp((*argvp)[1], "--help"))
+ int i;
+
+ for (i = 1 ; i < *argcp; i++) {
+ if (!strcmp((*argvp)[i], "--help"))
help();
- if (!strcmp((*argvp)[1], "--show-checks"))
+ if (!strcmp((*argvp)[i], "--show-checks"))
show_checks();
- if (!found && !strncmp((*argvp)[1], "--project=", 10)) {
- option_project_str = (*argvp)[1] + 10;
- (*argvp)[1] = (*argvp)[0];
- found = 1;
- }
- if (!found && !strncmp((*argvp)[1], "-p=", 3)) {
- option_project_str = (*argvp)[1] + 3;
- (*argvp)[1] = (*argvp)[0];
- found = 1;
- }
- if (!found && !strncmp((*argvp)[1], "--db-file=", 10)) {
- option_db_file = (*argvp)[1] + 10;
- (*argvp)[1] = (*argvp)[0];
- found = 1;
- }
- if (!found && !strncmp((*argvp)[1], "--data=", 7)) {
- option_datadir_str = (*argvp)[1] + 7;
- (*argvp)[1] = (*argvp)[0];
- found = 1;
- }
- if (!found && !strncmp((*argvp)[1], "--debug=", 8)) {
- option_debug_check = (*argvp)[1] + 8;
- (*argvp)[1] = (*argvp)[0];
- found = 1;
- }
- if (!found && strncmp((*argvp)[1], "--trace=", 8) == 0) {
- trace_variable = (*argvp)[1] + 8;
- (*argvp)[1] = (*argvp)[0];
- found = 1;
- }
- if (!found && strncmp((*argvp)[1], "--enable=", 9) == 0) {
- enable_disable_checks((*argvp)[1] + 9, 1);
+ if (!strncmp((*argvp)[i], "--project=", 10))
+ option_project_str = (*argvp)[i] + 10;
+
+ if (!strncmp((*argvp)[i], "-p=", 3))
+ option_project_str = (*argvp)[i] + 3;
+
+ if (!strncmp((*argvp)[i], "--db-file=", 10))
+ option_db_file = (*argvp)[i] + 10;
+
+ if (!strncmp((*argvp)[i], "--data=", 7))
+ option_datadir_str = (*argvp)[i] + 7;
+
+ if (!strncmp((*argvp)[i], "--debug=", 8))
+ option_debug_check = (*argvp)[i] + 8;
+
+ if (strncmp((*argvp)[i], "--trace=", 8) == 0)
+ trace_variable = (*argvp)[i] + 8;
+
+ if (strncmp((*argvp)[i], "--enable=", 9) == 0) {
+ enable_disable_checks((*argvp)[i] + 9, 1);
option_enable = 1;
- (*argvp)[1] = (*argvp)[0];
- found = 1;
}
- if (!found && strncmp((*argvp)[1], "--disable=", 10) == 0) {
- enable_disable_checks((*argvp)[1] + 10, 0);
+
+ if (strncmp((*argvp)[i], "--disable=", 10) == 0) {
+ enable_disable_checks((*argvp)[i] + 10, 0);
option_enable = 1;
option_disable = 1;
- (*argvp)[1] = (*argvp)[0];
- found = 1;
}
OPTION(fatal_checks);
@@ -247,10 +231,6 @@ void parse_args(int *argcp, char ***argvp)
OPTION(time);
OPTION(mem);
OPTION(no_db);
- if (!found)
- break;
- (*argcp)--;
- (*argvp)++;
}
if (strcmp(option_project_str, "smatch_generic") != 0)
--
2.14.1
reply other threads:[~2018-11-24 1:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=E1gQCRX-00068m-92@movementarian.org \
--to=levon@movementarian.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).