[Skiboot] [PATCH v3 3/4] external: simplify help output in xscom commands

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Thu Mar 10 21:33:07 AEDT 2016


On 03/09/2016 06:00 PM, Cédric Le Goater wrote:
> This kills a few booleans used to output version and help.
>
> Suggested-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
> Signed-off-by: Cédric Le Goater <clg at fr.ibm.com>
> ---
>   external/xscom-utils/getscom.c | 19 ++++++-------------
>   external/xscom-utils/getsram.c | 22 ++++++----------------
>   external/xscom-utils/putscom.c | 23 +++++++----------------
>   3 files changed, 19 insertions(+), 45 deletions(-)
>
> diff --git a/external/xscom-utils/getscom.c b/external/xscom-utils/getscom.c
> index 45bdf2c2df92..96dcace433cd 100644
> --- a/external/xscom-utils/getscom.c
> +++ b/external/xscom-utils/getscom.c
> @@ -28,6 +28,7 @@ static void print_usage(void)
>   	printf("usage: getscom [-c|--chip chip-id] addr\n");
>   	printf("       getscom -l|--list-chips\n");
>   	printf("       getscom -v|--version\n");
> +	exit(1);

So its doing what is expected (display usage and exit). Better exit(0) ?


>   }
>
>   static void print_chip_info(uint32_t chip_id)
> @@ -81,9 +82,7 @@ int main(int argc, char *argv[])
>   {
>   	uint64_t val, addr = -1ull;
>   	uint32_t def_chip, chip_id = 0xffffffff;
> -	bool show_help = false;
>   	bool list_chips = false;
> -	bool show_version = false;
>   	bool no_work = false;
>   	int rc;
>
> @@ -107,14 +106,14 @@ int main(int argc, char *argv[])
>   			chip_id = strtoul(optarg, NULL, 0);
>   			break;
>   		case 'h':
> -			show_help = true;
> +			print_usage();
>   			break;
>   		case 'l':
>   			list_chips = true;
>   			break;
>   		case 'v':
> -			show_version = true;
> -			break;
> +			printf("xscom utils version %s\n", VERSION_STR);
> +			exit(1);

exit(0)?

-Vasant



More information about the Skiboot mailing list