From: David Goulet Date: Fri, 27 Jan 2012 16:08:23 +0000 (-0500) Subject: Fix comments and usage output X-Git-Tag: v2.0-pre19~46 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=3183dbb0b0a687ececcadb3be0cde938dc19f57a;p=lttng-tools.git Fix comments and usage output Multiple fixes to comments in lttng and lttng-consumerd. Adds --list-commands as an arguments to ignore when auto spawning the session daemon from lttng cli. Usage of the consumerd now output on a stream and usage is set to stdout when asked with --help. Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c index a637a9042..5d1ad0682 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 kern-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,28 +119,28 @@ static int set_signal_handler(void) } /* - * usage function on stderr + * Usage function on stream file. */ -static void usage(void) +static void usage(FILE *fp) { - fprintf(stderr, "Usage: %s OPTIONS\n\nOptions:\n", progname); - fprintf(stderr, " -h, --help " + fprintf(fp, "Usage: %s OPTIONS\n\nOptions:\n", progname); + fprintf(fp, " -h, --help " "Display this usage.\n"); - fprintf(stderr, " -c, --consumerd-cmd-sock PATH " + fprintf(fp, " -c, --consumerd-cmd-sock PATH " "Specify path for the command socket\n"); - fprintf(stderr, " -e, --consumerd-err-sock PATH " + fprintf(fp, " -e, --consumerd-err-sock PATH " "Specify path for the error socket\n"); - fprintf(stderr, " -d, --daemonize " + fprintf(fp, " -d, --daemonize " "Start as a daemon.\n"); - fprintf(stderr, " -q, --quiet " + fprintf(fp, " -q, --quiet " "No output at all.\n"); - fprintf(stderr, " -v, --verbose " + fprintf(fp, " -v, --verbose " "Verbose mode. Activate DBG() macro.\n"); - fprintf(stderr, " -V, --version " + fprintf(fp, " -V, --version " "Show version number.\n"); - fprintf(stderr, " -k, --kernel " + fprintf(fp, " -k, --kernel " "Consumer kernel buffers (default).\n"); - fprintf(stderr, " -u, --ust " + fprintf(fp, " -u, --ust " "Consumer UST buffers.%s\n", #ifdef HAVE_LIBLTTNG_UST_CTL "" @@ -196,8 +196,8 @@ static void parse_args(int argc, char **argv) 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 @@ static void parse_args(int argc, char **argv) break; #endif default: - usage(); + usage(stderr); exit(EXIT_FAILURE); } } @@ -310,7 +310,7 @@ int main(int argc, char **argv) ret = lttcomm_connect_unix_sock(error_sock_path); /* not a fatal error, but all communication with lttng-sessiond will fail */ if (ret < 0) { - WARN("Cannot connect to error socket, is lttng-sessiond started ?"); + WARN("Cannot connect to error socket (is lttng-sessiond started ?)"); } lttng_consumer_set_error_sock(ctx, ret); diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index 36d4c913d..5988c419d 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -362,7 +362,7 @@ static int check_sessiond(void) 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; @@ -384,7 +384,7 @@ static int check_sessiond(void) 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; } } @@ -406,7 +406,8 @@ static int check_args_no_sessiond(int argc, char **argv) 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; } } @@ -415,10 +416,9 @@ static int check_args_no_sessiond(int argc, char **argv) } /* - * parse_args + * Parse command line arguments. * - * Parse command line arguments. - * Return 0 if OK, else -1 + * Return 0 if OK, else -1 */ static int parse_args(int argc, char **argv) { @@ -432,8 +432,8 @@ static int parse_args(int argc, char **argv) while ((opt = getopt_long(argc, argv, "+hnvqg:", long_options, NULL)) != -1) { switch (opt) { case 'h': - usage(stderr); - goto error; + usage(stdout); + goto end; case 'v': opt_verbose += 1; break; @@ -452,11 +452,11 @@ static int parse_args(int argc, char **argv) case OPT_DUMP_OPTIONS: list_options(stdout); ret = 0; - goto error; + goto end; case OPT_DUMP_COMMANDS: list_commands(stdout); ret = 0; - goto error; + goto end; default: usage(stderr); goto error; @@ -494,6 +494,7 @@ static int parse_args(int argc, char **argv) goto error; } +end: return 0; error: diff --git a/src/bin/lttng/utils.c b/src/bin/lttng/utils.c index 635bf7734..1f491db1b 100644 --- a/src/bin/lttng/utils.c +++ b/src/bin/lttng/utils.c @@ -46,9 +46,12 @@ char *get_session_name(void) goto error; } -error: + DBG2("Config file path found: %s", path); DBG("Session name found: %s", session_name); return session_name; + +error: + return NULL; }