[lttng-dev] [PATCH] lttng-tools lttng-consumerd: help option should print usage() to stdout, exit as a success

Thibault, Daniel Daniel.Thibault at drdc-rddc.gc.ca
Wed Jan 25 15:50:11 EST 2012


TODO: "kernctl" now known as "kernel-ctl"
usage(): changed signature to (FILE *stream), remove periods from descriptions, fix alignment
parse_args(): --help prints to stdout, exits as a success

------------------------------
>From 41c9bc8f96b240106009edd98d3c26b83252e133 Wed, 25 Jan 2012 15:41:59 -0500
From: Daniel U. Thibault <daniel.thibault at drdc-rddc.gc.ca>
Date: Wed, 25 Jan 2012 15:41:38 -0500
Subject: [PATCH] lttng-tools lttng-consumerd: help option should print usage() to stdout, exit as a success

diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c
index a637a90..42beca3 100644
--- a/src/bin/lttng-consumerd/lttng-consumerd.c
+++ b/src/bin/lttng-consumerd/lttng-consumerd.c
@@ -49,12 +49,12 @@
 
 #include "lttng-consumerd.h"
 
-/* TODO : support UST (all direct kernctl accesses). */
+/* TODO : support UST (all direct kernel-ctl accesses). */
 
 /* the two threads (receive fd and poll) */
 static pthread_t threads[2];
 
-/* to count the number of time the user pressed ctrl+c */
+/* to count the number of times the user pressed ctrl+c */
 static int sigintcount = 0;
 
 /* Argument variables */
@@ -119,33 +119,33 @@
 }
 
 /*
- * usage function on stderr
+ * usage function on stream
  */
-static void usage(void)
+static void usage(FILE *stream)
 {
-	fprintf(stderr, "Usage: %s OPTIONS\n\nOptions:\n", progname);
-	fprintf(stderr, "  -h, --help                         "
-			"Display this usage.\n");
-	fprintf(stderr, "  -c, --consumerd-cmd-sock PATH     "
+	fprintf(stream, "Usage: %s OPTIONS\n\nOptions:\n", progname);
+	fprintf(stream, "  -h, --help                         "
+			"Display this usage\n");
+	fprintf(stream, "  -c, --consumerd-cmd-sock PATH      "
 			"Specify path for the command socket\n");
-	fprintf(stderr, "  -e, --consumerd-err-sock PATH     "
+	fprintf(stream, "  -e, --consumerd-err-sock PATH      "
 			"Specify path for the error socket\n");
-	fprintf(stderr, "  -d, --daemonize                    "
-			"Start as a daemon.\n");
-	fprintf(stderr, "  -q, --quiet                        "
-			"No output at all.\n");
-	fprintf(stderr, "  -v, --verbose                      "
-			"Verbose mode. Activate DBG() macro.\n");
-	fprintf(stderr, "  -V, --version                      "
-			"Show version number.\n");
-	fprintf(stderr, "  -k, --kernel                       "
-			"Consumer kernel buffers (default).\n");
-	fprintf(stderr, "  -u, --ust                          "
-			"Consumer UST buffers.%s\n",
+	fprintf(stream, "  -d, --daemonize                    "
+			"Start as a daemon\n");
+	fprintf(stream, "  -q, --quiet                        "
+			"No output at all\n");
+	fprintf(stream, "  -v, --verbose                      "
+			"Verbose mode (Activates DBG() macro)\n");
+	fprintf(stream, "  -V, --version                      "
+			"Show version number and exit\n");
+	fprintf(stream, "  -k, --kernel                       "
+			"Consumer kernel buffers (default)\n");
+	fprintf(stream, "  -u, --ust                          "
+			"Consumer UST buffers%s\n",
 #ifdef HAVE_LIBLTTNG_UST_CTL
 			""
 #else
@@ -196,8 +196,8 @@
 			opt_daemon = 1;
 			break;
 		case 'h':
-			usage();
-			exit(EXIT_FAILURE);
+			usage(stdout);
+			exit(EXIT_SUCCESS);
 		case 'q':
 			opt_quiet = 1;
 			break;
@@ -222,7 +222,7 @@
 			break;
 #endif
 		default:
-			usage();
+			usage(stderr);
 			exit(EXIT_FAILURE);
 		}
 	}
------------------------------

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