[lttng-dev] [PATCH] help, list-commands, list-options yield normal exits

David Goulet dgoulet at efficios.com
Fri Jan 27 10:56:02 EST 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



On 12-01-25 02:29 PM, Thibault, Daniel wrote:
> lttng-tools lttng.c check_sessiond(): Improve error messages
> check_args_no_sessiond(): Add "--list-commands" to the "no daemon" options
> parse_args(): --help, --list-commands and --list-options yield normal exits, not errors
> main(): punctuation in comment
> ------------------------------
> From f6b2ceac855df3312c09cbc14b0ff75fb33b19c8 Wed, 25 Jan 2012 14:22:53 -0500
> From: Daniel U. Thibault <daniel.thibault at drdc-rddc.gc.ca>
> Date: Wed, 25 Jan 2012 14:22:42 -0500
> Subject: [PATCH] help, list-commands, list-options yield normal exits
> 
> diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c
> index 36723be..4ffabee 100644
> --- a/src/bin/lttng/lttng.c
> +++ b/src/bin/lttng/lttng.c
> @@ -367,7 +367,7 @@
>  		if (opt_sessiond_path != NULL) {
>  			ret = access(opt_sessiond_path, F_OK | X_OK);
>  			if (ret < 0) {
> -				ERR("No such file: %s", opt_sessiond_path);
> +				ERR("No such file or access denied: %s", opt_sessiond_path);

Fixed

>  				goto end;
>  			}
>  			pathname = opt_sessiond_path;
> @@ -389,7 +389,7 @@
>  		ret = spawn_sessiond(pathname);
>  		free(alloc_pathname);
>  		if (ret < 0) {
> -			ERR("Problem occurs when starting %s", pathname);
> +			ERR("Problem occurred when starting %s", pathname);

Fixed

>  			goto end;
>  		}
>  	}
> @@ -411,7 +411,8 @@
>  	for (i = 0; i < argc; i++) {
>  		if ((strncmp(argv[i], "-h", sizeof("-h")) == 0) ||
>  				strncmp(argv[i], "--h", sizeof("--h")) == 0 ||
> -				strncmp(argv[i], "--list-options", sizeof("--list-options")) == 0) {
> +				strncmp(argv[i], "--list-options", sizeof("--list-options")) == 0 ||
> +				strncmp(argv[i], "--list-commands", sizeof("--list-commands")) == 0) {

Yes! Fixed

>  			return 1;
>  		}
>  	}
> @@ -437,8 +438,8 @@
>  	while ((opt = getopt_long(argc, argv, "+hnvqg:", long_options, NULL)) != -1) {
>  		switch (opt) {
>  		case 'h':
> -			usage(stderr);
> -			goto error;
> +			usage(stdout);
> +			goto success;

I agree for the stdout since the user requested the --help. For the sake of code
"normalization", I used "goto end;" instead of success.

David

>  		case 'v':
>  			opt_verbose += 1;
>  			break;
> @@ -457,11 +458,11 @@
>  		case OPT_DUMP_OPTIONS:
>  			list_options(stdout);
>  			ret = 0;
> -			goto error;
> +			goto success;
>  		case OPT_DUMP_COMMANDS:
>  			list_commands(stdout);
>  			ret = 0;
> -			goto error;
> +			goto success;
>  		default:
>  			usage(stderr);
>  			goto error;
> @@ -498,7 +499,7 @@
>  		}
>  		goto error;
>  	}
> -
> +success:
>  	return 0;
>  
>  error:
> @@ -515,7 +516,7 @@
>  
>  	progname = argv[0] ? argv[0] : "lttng";
>  
> -	/* For Mathieu Desnoyers aka Dr Tracing */
> +	/* For Mathieu Desnoyers a.k.a. Dr. Tracing */
>  	if (strncmp(progname, "drtrace", 7) == 0 ||
>  			strncmp("compudj", getenv("USER"), 7) == 0) {
>  		MSG("%c[%d;%dmWelcome back Dr Tracing!%c[%dm\n", 27,1,33,27,0);
> ------------------------------
> 
> Daniel U. Thibault
> R & D pour la défense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier)
> Système de systèmes (SdS) / System of Systems (SoS)
> Solutions informatiques et expérimentations (SIE) / Computing Solutions and Experimentations (CSE)
> 2459 Boul. Pie XI Nord
> Québec, QC  G3J 1X5
> CANADA
> Vox : (418) 844-4000 x4245
> Fax : (418) 844-4538
> NAC: 918V QSDJ
> Gouvernement du Canada / Government of Canada
> <http://www.valcartier.drdc-rddc.gc.ca/>
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEcBAEBAgAGBQJPIskSAAoJEELoaioR9I02tSAH/2WrStpd2yNhm/Ixkqrhvz81
W/DgyRbPa2lXT36Ygzd6Og8ZFXN1g/m6+GlcW3RmwGQVkwBK3cUFupn8k7xQ02PV
kVR9MK0zBEJkwS2W94XSWDS8M1MwF96N/KRxwiurQy5CpPu3jut80sPW09xKeLG0
F4eDOeNS6sgiPfOBDapMUBJimLbNCAU4rA4bVtX5jjRNMfLHJVWeKamCtFQkgsdX
175YfbA8O9rs8KGPJPjcKtF+49sFeWI7xtn15PYB8zs2mKUvdTVMFG5UQ2SoALS8
rt4hj7dcEpAXLjfsMQIxOLNCbCD7SUXwDNNeUEd2cmKWMCpQXzR19PXDL7zkA2s=
=akOr
-----END PGP SIGNATURE-----



More information about the lttng-dev mailing list