Fix comments and usage output
authorDavid Goulet <dgoulet@efficios.com>
Fri, 27 Jan 2012 16:08:23 +0000 (11:08 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 27 Jan 2012 16:11:02 +0000 (11:11 -0500)
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 <dgoulet@efficios.com>
src/bin/lttng-consumerd/lttng-consumerd.c
src/bin/lttng/lttng.c
src/bin/lttng/utils.c

index a637a904244979b5f8b0a310e458684a03162d19..5d1ad06829f3539cd9619d27467c89580dbe569a 100644 (file)
 
 #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);
 
index 36d4c913df48ab681cbfac27e428c3f7888d339c..5988c419d5febc17cf1856f66b6ced21b4d80ef5 100644 (file)
@@ -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:
index 635bf7734d244a0694135c5ac3b827644d72d9a8..1f491db1b89e0095d33ce7ee603338f4f7f400c2 100644 (file)
@@ -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;
 }
 
 
This page took 0.029752 seconds and 4 git commands to generate.