From e67b6d2b4b3400d5e29cf2ef3eac04824c3eadf9 Mon Sep 17 00:00:00 2001 From: Gyorgy Jeney Date: Sun, 16 Dec 2007 21:15:55 -0800 Subject: [PATCH] Fix command line handling of warning flags. Prevent an overflow of command line flags if the -Wall argument is used multiple times, and fix processing of individual flags that may be in the beginning of the warnings flag buffer. --- driver/main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/driver/main.c b/driver/main.c index fea8b3c7c..b37d26a5c 100644 --- a/driver/main.c +++ b/driver/main.c @@ -342,31 +342,32 @@ static int t_default(char*cmd, unsigned ncmd) static void process_warning_switch(const char*name) { if (strcmp(name,"all") == 0) { - strcat(warning_flags, "ipt"); - + process_warning_switch("implicit"); + process_warning_switch("portbind"); + process_warning_switch("timescale"); } else if (strcmp(name,"implicit") == 0) { - if (! strchr(warning_flags+2, 'i')) + if (! strchr(warning_flags, 'i')) strcat(warning_flags, "i"); } else if (strcmp(name,"portbind") == 0) { - if (! strchr(warning_flags+2, 'p')) + if (! strchr(warning_flags, 'p')) strcat(warning_flags, "p"); } else if (strcmp(name,"timescale") == 0) { - if (! strchr(warning_flags+2, 't')) + if (! strchr(warning_flags, 't')) strcat(warning_flags, "t"); } else if (strcmp(name,"no-implicit") == 0) { - char*cp = strchr(warning_flags+2, 'i'); + char*cp = strchr(warning_flags, 'i'); if (cp) while (*cp) { cp[0] = cp[1]; cp += 1; } } else if (strcmp(name,"no-portbind") == 0) { - char*cp = strchr(warning_flags+2, 'p'); + char*cp = strchr(warning_flags, 'p'); if (cp) while (*cp) { cp[0] = cp[1]; cp += 1; } } else if (strcmp(name,"no-timescale") == 0) { - char*cp = strchr(warning_flags+2, 't'); + char*cp = strchr(warning_flags, 't'); if (cp) while (*cp) { cp[0] = cp[1]; cp += 1;