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

login
register
mail settings
Submitter Colin King
Date Nov. 22, 2012, 4:30 p.m.
Message ID <1353601834-5335-3-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/201081/
State Accepted
Headers show

Comments

Colin King - Nov. 22, 2012, 4:30 p.m.
From: Colin Ian King <colin.king@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@canonical.com>
---
 src/lib/src/fwts_framework.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
Keng-Yu Lin - Nov. 27, 2012, 8:11 a.m.
On Fri, Nov 23, 2012 at 12:30 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@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@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
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Ivan Hu - Nov. 28, 2012, 9:07 a.m.
On 11/23/2012 12:30 AM, Colin King wrote:
> From: Colin Ian King <colin.king@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@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) {
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>

Patch

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) {