Cleanup: enable_events.c: fix erroneous comment
[lttng-tools.git] / src / bin / lttng / commands / disable_events.c
index 14fa2ff151f47687f144cc8bef245f59418aa19e..290e72791e034fb8060ffda8cfd1e8c77ef5e9ea 100644 (file)
@@ -15,7 +15,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#define _GNU_SOURCE
 #define _LGPL_SOURCE
 #include <popt.h>
 #include <stdio.h>
@@ -41,6 +40,12 @@ static int opt_log4j;
 static int opt_python;
 static int opt_event_type;
 
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-disable-event.1.h>
+;
+#endif
+
 enum {
        OPT_HELP = 1,
        OPT_TYPE_SYSCALL,
@@ -74,34 +79,6 @@ static struct poptOption long_options[] = {
        {0, 0, 0, 0, 0, 0, 0}
 };
 
-/*
- * usage
- */
-static void usage(FILE *ofp)
-{
-       fprintf(ofp, "usage: lttng disable-event NAME[,NAME2,...] (-k | -u) [OPTIONS]\n");
-       fprintf(ofp, "\n");
-       fprintf(ofp, "Options:\n");
-       fprintf(ofp, "  -h, --help               Show this help\n");
-       fprintf(ofp, "      --list-options       Simple listing of options\n");
-       fprintf(ofp, "  -s, --session NAME       Apply to session name\n");
-       fprintf(ofp, "  -c, --channel NAME       Apply to this channel\n");
-       fprintf(ofp, "  -a, --all-events         Disable all tracepoints\n");
-       fprintf(ofp, "  -k, --kernel             Apply for the kernel tracer\n");
-       fprintf(ofp, "  -u, --userspace          Apply to the user-space tracer\n");
-       fprintf(ofp, "  -j, --jul                Apply for Java application using JUL\n");
-       fprintf(ofp, "  -l, --log4j              Apply to Java application using LOG4j\n");
-       fprintf(ofp, "  -p, --python             Apply to Python application using logging\n");
-       fprintf(ofp, "\n");
-       fprintf(ofp, "Event type options (Only supported with kernel domain):\n");
-       fprintf(ofp, "      --all                All event types (default)\n");
-       fprintf(ofp, "      --tracepoint         Tracepoint event\n");
-       fprintf(ofp, "      --syscall            System call event\n");
-       fprintf(ofp, "      --probe              Probe event\n");
-       fprintf(ofp, "      --function           Function event\n");
-       fprintf(ofp, "\n");
-}
-
 static
 const char *print_channel_name(const char *name)
 {
@@ -351,6 +328,7 @@ int cmd_disable_events(int argc, const char **argv)
        int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
        static poptContext pc;
        char *session_name = NULL;
+       const char *leftover = NULL;
        int event_type = -1;
 
        pc = poptGetContext(NULL, argc, argv, long_options, 0);
@@ -362,7 +340,7 @@ int cmd_disable_events(int argc, const char **argv)
        while ((opt = poptGetNextOpt(pc)) != -1) {
                switch (opt) {
                case OPT_HELP:
-                       usage(stdout);
+                       SHOW_HELP();
                        goto end;
                case OPT_TYPE_SYSCALL:
                        opt_event_type = LTTNG_EVENT_SYSCALL;
@@ -383,7 +361,6 @@ int cmd_disable_events(int argc, const char **argv)
                        list_cmd_options(stdout, long_options);
                        goto end;
                default:
-                       usage(stderr);
                        ret = CMD_UNDEFINED;
                        goto end;
                }
@@ -410,8 +387,7 @@ int cmd_disable_events(int argc, const char **argv)
        /* Ust and agent only support ALL event type */
        if ((opt_userspace || opt_jul || opt_log4j || opt_python)
                        && opt_event_type != LTTNG_EVENT_ALL) {
-               ERR("UST and agent (-j | -l | -p) event(s) disabling based on event type is not supported.\n");
-               usage(stderr);
+               ERR("Disabling userspace and agent (-j | -l | -p) event(s) based on instrumentation type is not supported.\n");
                ret = CMD_ERROR;
                goto end;
        }
@@ -419,7 +395,13 @@ int cmd_disable_events(int argc, const char **argv)
        opt_event_list = (char*) poptGetArg(pc);
        if (opt_event_list == NULL && opt_disable_all == 0) {
                ERR("Missing event name(s).\n");
-               usage(stderr);
+               ret = CMD_ERROR;
+               goto end;
+       }
+
+       leftover = poptGetArg(pc);
+       if (leftover) {
+               ERR("Unknown argument: %s", leftover);
                ret = CMD_ERROR;
                goto end;
        }
@@ -499,7 +481,7 @@ end:
                ret = ret ? ret : LTTNG_ERR_MI_IO_FAIL;
        }
 
-       /* Overwrite ret if an error occured in disable_events */
+       /* Overwrite ret if an error occurred in disable_events */
        ret = command_ret ? command_ret : ret;
 
        poptFreeContext(pc);
This page took 0.025655 seconds and 4 git commands to generate.