Bump UST ABI major version for 2.3 release
[lttng-tools.git] / src / bin / lttng / commands / enable_events.c
index 0e6bb55d8bc7b618fadcc830c1a7ee736145a3c3..18793ae095a77cbe8365f09ac0576a06011ea407 100644 (file)
@@ -268,7 +268,11 @@ int loglevel_str_to_value(const char *inputstr)
        int i = 0;
        char str[LTTNG_SYMBOL_NAME_LEN];
 
-       while (i < LTTNG_SYMBOL_NAME_LEN && inputstr[i] != '\0') {
+       /*
+        * Loop up to LTTNG_SYMBOL_NAME_LEN minus one because the NULL bytes is
+        * added at the end of the loop so a the upper bound we avoid the overflow.
+        */
+       while (i < (LTTNG_SYMBOL_NAME_LEN - 1) && inputstr[i] != '\0') {
                str[i] = toupper(inputstr[i]);
                i++;
        }
@@ -438,7 +442,6 @@ static int enable_events(char *session_name)
                        ret = lttng_enable_event_with_filter(handle, &ev, channel_name,
                                                opt_filter);
                        if (ret < 0) {
-                               fprintf(stderr, "Ret filter: %d\n", ret);
                                switch (-ret) {
                                case LTTNG_ERR_FILTER_EXIST:
                                        WARN("Filter on events is already enabled"
@@ -447,9 +450,8 @@ static int enable_events(char *session_name)
                                        break;
                                case LTTNG_ERR_FILTER_INVAL:
                                case LTTNG_ERR_FILTER_NOMEM:
-                                       ERR("%s", lttng_strerror(ret));
                                default:
-                                       ERR("Setting filter: '%s'", opt_filter);
+                                       ERR("%s", lttng_strerror(ret));
                                        break;
                                }
                                goto error;
@@ -634,6 +636,7 @@ int cmd_enable_events(int argc, const char **argv)
        int opt, ret = CMD_SUCCESS;
        static poptContext pc;
        char *session_name = NULL;
+       int event_type = -1;
 
        pc = poptGetContext(NULL, argc, argv, long_options, 0);
        poptReadDefaultConfig(pc, 0);
@@ -682,6 +685,17 @@ int cmd_enable_events(int argc, const char **argv)
                        ret = CMD_UNDEFINED;
                        goto end;
                }
+
+               /* Validate event type. Multiple event type are not supported. */
+               if (event_type == -1) {
+                       event_type = opt_event_type;
+               } else {
+                       if (event_type != opt_event_type) {
+                               ERR("Multiple event type not supported.");
+                               ret = CMD_ERROR;
+                               goto end;
+                       }
+               }
        }
 
        opt_event_list = (char*) poptGetArg(pc);
This page took 0.024127 seconds and 4 git commands to generate.