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

Thibault, Daniel Daniel.Thibault at drdc-rddc.gc.ca
Wed Jan 25 14:29:06 EST 2012


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



More information about the lttng-dev mailing list