[PATCH 2/3] lib: fwts_framework: sanity check new options

Colin King colin.king at canonical.com
Thu Nov 22 16:30:33 UTC 2012


From: Colin Ian King <colin.king at canonical.com>

The --filter-error-discard and --filter-error-keep options are
mutually exclusive.  So check for this.

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/lib/src/fwts_framework.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
index 1f01466..eac05bd 100644
--- a/src/lib/src/fwts_framework.c
+++ b/src/lib/src/fwts_framework.c
@@ -1233,6 +1233,16 @@ int fwts_framework_args(const int argc, char **argv)
 		goto tidy_close;
 	}
 
+	/* These are mutually exclusive, both cannot have items */
+	if ((fwts_list_len(&fw->errors_filter_keep) > 0) &&
+	    (fwts_list_len(&fw->errors_filter_discard) > 0)) {
+		fprintf(stderr,
+			"The --filter-error-discard and --filter-error-keep options are\n"
+			"mutually exclusive.  Specify one or the other, but not both.\n");
+		ret = FWTS_ERROR;
+		goto tidy_close;
+	}
+
 	/* Ensure we have just one log type specified for non-filename logging */
 	if (fwts_log_type_count(fw->log_type) > 1 &&
 	    fwts_log_get_filename_type(fw->results_logname) != LOG_FILENAME_TYPE_FILE) {
-- 
1.8.0




More information about the fwts-devel mailing list