Patchwork [3/3] lib: fwts_framework: handle --log-type parse errors

login
register
mail settings
Submitter Colin King
Date June 11, 2012, 10 a.m.
Message ID <1339408838-31877-4-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/164112/
State Accepted
Headers show

Comments

Colin King - June 11, 2012, 10 a.m.
From: Colin Ian King <colin.king@canonical.com>

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_framework.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
Chris Van Hoof - June 11, 2012, 3:54 p.m.
On 06/11/2012 06:00 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_framework.c |   13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index a6c2ba2..b9c6f58 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -981,8 +981,8 @@ int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
>  			fwts_iasl_disassemble_all_to_file(fw);
>  			return FWTS_COMPLETE;
>  		case 32: /* --log-type */
> -			fwts_framework_log_type_parse(fw, optarg);
> -			/* FIX ME - check return */
> +			if (fwts_framework_log_type_parse(fw, optarg) != FWTS_OK)
> +				return FWTS_ERROR;
>  			break;
>  		}
>  		break;
> @@ -1099,8 +1099,15 @@ int fwts_framework_args(const int argc, char **argv)
>  	fwts_list_init(&tests_to_run);
>  	fwts_list_init(&tests_to_skip);
>  
> -	if (fwts_args_parse(fw, argc, argv) != FWTS_OK)
> +	switch (fwts_args_parse(fw, argc, argv)) {
> +	case FWTS_OK:
> +		break;
> +	case FWTS_COMPLETE:		/* All done, e.g. --help, --version */
> +		goto tidy_close;
> +	default:
> +		ret = FWTS_ERROR;	/* Parsing error, or out of memory etc */
>  		goto tidy_close;
> +	}
>  
>  	for (i=1; i<argc; i++)
>  		if (!strcmp(argv[i], "-")) {

Gave this a spin with fwts -b --log-type html,plaintext ... results can
be found here:

http://ouwish.com/~vanhoof/pickup/cking/fwts_2012-06-11/

Tested-by: Chris Van Hoof <vanhoof@canonical.com>
Keng-Yu Lin - June 13, 2012, 9:50 a.m.
On Mon, Jun 11, 2012 at 6:00 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_framework.c |   13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index a6c2ba2..b9c6f58 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -981,8 +981,8 @@ int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
>                        fwts_iasl_disassemble_all_to_file(fw);
>                        return FWTS_COMPLETE;
>                case 32: /* --log-type */
> -                       fwts_framework_log_type_parse(fw, optarg);
> -                       /* FIX ME - check return */
> +                       if (fwts_framework_log_type_parse(fw, optarg) != FWTS_OK)
> +                               return FWTS_ERROR;
>                        break;
>                }
>                break;
> @@ -1099,8 +1099,15 @@ int fwts_framework_args(const int argc, char **argv)
>        fwts_list_init(&tests_to_run);
>        fwts_list_init(&tests_to_skip);
>
> -       if (fwts_args_parse(fw, argc, argv) != FWTS_OK)
> +       switch (fwts_args_parse(fw, argc, argv)) {
> +       case FWTS_OK:
> +               break;
> +       case FWTS_COMPLETE:             /* All done, e.g. --help, --version */
> +               goto tidy_close;
> +       default:
> +               ret = FWTS_ERROR;       /* Parsing error, or out of memory etc */
>                goto tidy_close;
> +       }
>
>        for (i=1; i<argc; i++)
>                if (!strcmp(argv[i], "-")) {
> --
> 1.7.10.4
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Alex Hung - June 18, 2012, 3:12 a.m.
On 06/11/2012 06:00 PM, Colin King wrote:
> From: Colin Ian King<colin.king@canonical.com>
>
> Signed-off-by: Colin Ian King<colin.king@canonical.com>
> ---
>   src/lib/src/fwts_framework.c |   13 ++++++++++---
>   1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index a6c2ba2..b9c6f58 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -981,8 +981,8 @@ int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
>   			fwts_iasl_disassemble_all_to_file(fw);
>   			return FWTS_COMPLETE;
>   		case 32: /* --log-type */
> -			fwts_framework_log_type_parse(fw, optarg);
> -			/* FIX ME - check return */
> +			if (fwts_framework_log_type_parse(fw, optarg) != FWTS_OK)
> +				return FWTS_ERROR;
>   			break;
>   		}
>   		break;
> @@ -1099,8 +1099,15 @@ int fwts_framework_args(const int argc, char **argv)
>   	fwts_list_init(&tests_to_run);
>   	fwts_list_init(&tests_to_skip);
>
> -	if (fwts_args_parse(fw, argc, argv) != FWTS_OK)
> +	switch (fwts_args_parse(fw, argc, argv)) {
> +	case FWTS_OK:
> +		break;
> +	case FWTS_COMPLETE:		/* All done, e.g. --help, --version */
> +		goto tidy_close;
> +	default:
> +		ret = FWTS_ERROR;	/* Parsing error, or out of memory etc */
>   		goto tidy_close;
> +	}
>
>   	for (i=1; i<argc; i++)
>   		if (!strcmp(argv[i], "-")) {

Acked-by: Alex Hung <alex.hung@canonical.com>

Patch

diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
index a6c2ba2..b9c6f58 100644
--- a/src/lib/src/fwts_framework.c
+++ b/src/lib/src/fwts_framework.c
@@ -981,8 +981,8 @@  int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
 			fwts_iasl_disassemble_all_to_file(fw);
 			return FWTS_COMPLETE;
 		case 32: /* --log-type */
-			fwts_framework_log_type_parse(fw, optarg);
-			/* FIX ME - check return */
+			if (fwts_framework_log_type_parse(fw, optarg) != FWTS_OK)
+				return FWTS_ERROR;
 			break;
 		}
 		break;
@@ -1099,8 +1099,15 @@  int fwts_framework_args(const int argc, char **argv)
 	fwts_list_init(&tests_to_run);
 	fwts_list_init(&tests_to_skip);
 
-	if (fwts_args_parse(fw, argc, argv) != FWTS_OK)
+	switch (fwts_args_parse(fw, argc, argv)) {
+	case FWTS_OK:
+		break;
+	case FWTS_COMPLETE:		/* All done, e.g. --help, --version */
+		goto tidy_close;
+	default:
+		ret = FWTS_ERROR;	/* Parsing error, or out of memory etc */
 		goto tidy_close;
+	}
 
 	for (i=1; i<argc; i++)
 		if (!strcmp(argv[i], "-")) {