[Intel-gfx] [PATCH i-g-t 7/8] lib: always warn about unknown options

Gore, Tim tim.gore at intel.com
Thu Jul 24 12:33:34 CEST 2014


Yes, this looks sensible.

> -----Original Message-----
> From: Thomas Wood [mailto:thomas.wood at intel.com]
> Sent: Wednesday, July 23, 2014 11:58 AM
> To: intel-gfx at lists.freedesktop.org
> Cc: Gore, Tim; daniel.vetter at ffwll.ch
> Subject: [PATCH i-g-t 7/8] lib: always warn about unknown options
> 
> All tests can now register extra options, so there should not be any unknown
> options.
> 
> Signed-off-by: Thomas Wood <thomas.wood at intel.com>
Reviewed-by: Tim Gore <tim.gore at intel.com>

> ---
>  lib/igt_core.c | 27 ++++-----------------------
>  1 file changed, 4 insertions(+), 23 deletions(-)
> 
> diff --git a/lib/igt_core.c b/lib/igt_core.c index 0867c27..42b22fc 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -362,17 +362,9 @@ static int common_init(int argc, char **argv,
>  			ret = -1;
>  			goto out;
>  		case '?':
> -			if (opterr) {
> -				print_usage(command_str, help_str, true);
> -				ret = -2;
> -				goto out;
> -			}
> -			/*
> -			 * Just ignore the error, since the unknown argument
> -			 * can be something the caller understands and will
> -			 * parse by doing a second getopt scanning.
> -			 */
> -			break;
> +			print_usage(command_str, help_str, true);
> +			ret = -2;
> +			goto out;
>  		default:
>  			ret = extra_opt_handler(c, option_index);
>  			if (ret)
> @@ -475,18 +467,7 @@ void igt_subtest_init(int argc, char **argv)
>   */
>  void igt_simple_init(int argc, char **argv)  {
> -	int ret;
> -
> -	/* supress getopt errors about unknown options */
> -	opterr = 0;
> -
> -	ret = common_init(argc, argv, NULL, NULL, NULL, NULL);
> -	if (ret < 0)
> -		/* exit with no error for -h/--help */
> -		exit(ret == -1 ? 0 : ret);
> -
> -	/* reset opt parsing */
> -	optind = 1;
> +	common_init(argc, argv, NULL, NULL, NULL, NULL);
>  }
> 
>  /**
> --
> 1.9.3




More information about the Intel-gfx mailing list