Powered by Linux
[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. — Semantic Matching Tool

[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 Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: John Levon <levon@xxxxxxxxxxxxxxxxx>
---
 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




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux