Fix: add missing semicolons after MSG, DBG, ERR print macros
[lttng-tools.git] / src / bin / lttng-sessiond / save.c
index 2f5a7fb2988a5eb9942194a677873125d019fd62..77b75e363ac81da55c2b9be7a55bd2dbbd261417 100644 (file)
@@ -500,57 +500,6 @@ end:
        return ret;
 }
 
-static
-int save_kernel_syscall(struct config_writer *writer,
-               struct ltt_kernel_channel *kchan)
-{
-       int ret, i;
-       ssize_t count;
-       struct lttng_event *events = NULL;
-
-       assert(writer);
-       assert(kchan);
-
-       count = syscall_list_channel(kchan, &events, 0);
-       if (!count) {
-               /* No syscalls, just gracefully return. */
-               ret = 0;
-               goto end;
-       }
-
-       for (i = 0; i < count; i++) {
-               struct ltt_kernel_event *kevent;
-
-               /* Create a temporary kevent in order to save it. */
-               /*
-                * TODO: struct lttng_event does not really work for a filter,
-                * but unfortunately, it is exposed as external API (and used as
-                * internal representation. Using NULL meanwhile.
-                */
-               kevent = trace_kernel_create_event(&events[i],
-                       NULL, NULL);
-               if (!kevent) {
-                       ret = -ENOMEM;
-                       goto end;
-               }
-               /* Init list in order so the destroy call can del the node. */
-               CDS_INIT_LIST_HEAD(&kevent->list);
-
-               ret = save_kernel_event(writer, kevent);
-               trace_kernel_destroy_event(kevent);
-               if (ret) {
-                       goto end;
-               }
-       }
-
-       /* Everything went well */
-       ret = 0;
-
-end:
-       free(events);
-       return ret;
-}
-
 static
 int save_kernel_events(struct config_writer *writer,
        struct ltt_kernel_channel *kchan)
@@ -571,12 +520,6 @@ int save_kernel_events(struct config_writer *writer,
                }
        }
 
-       /* Save syscalls if any. */
-       ret = save_kernel_syscall(writer, kchan);
-       if (ret) {
-               goto end;
-       }
-
        /* /events */
        ret = config_writer_close_element(writer);
        if (ret) {
@@ -742,16 +685,41 @@ end:
 }
 
 static
-void init_ust_event_from_agent_event(struct ltt_ust_event *ust_event,
+int init_ust_event_from_agent_event(struct ltt_ust_event *ust_event,
                struct agent_event *agent_event)
 {
+       int ret = 0;
+       enum lttng_ust_loglevel_type ust_loglevel_type;
+
        ust_event->enabled = agent_event->enabled;
        ust_event->attr.instrumentation = LTTNG_UST_TRACEPOINT;
-       strncpy(ust_event->attr.name, agent_event->name, LTTNG_SYMBOL_NAME_LEN);
-       ust_event->attr.loglevel_type = agent_event->loglevel_type;
-       ust_event->attr.loglevel = agent_event->loglevel;
+       if (lttng_strncpy(ust_event->attr.name, agent_event->name,
+                       LTTNG_SYMBOL_NAME_LEN)) {
+               ret = -1;
+               goto end;
+       }
+       switch (agent_event->loglevel_type) {
+       case LTTNG_EVENT_LOGLEVEL_ALL:
+               ust_loglevel_type = LTTNG_UST_LOGLEVEL_ALL;
+               break;
+       case LTTNG_EVENT_LOGLEVEL_SINGLE:
+               ust_loglevel_type = LTTNG_UST_LOGLEVEL_SINGLE;
+               break;
+       case LTTNG_EVENT_LOGLEVEL_RANGE:
+               ust_loglevel_type = LTTNG_UST_LOGLEVEL_RANGE;
+               break;
+       default:
+               ERR("Invalid agent_event loglevel_type.");
+               ret = -1;
+               goto end;
+       }
+
+       ust_event->attr.loglevel_type = ust_loglevel_type;
+       ust_event->attr.loglevel = agent_event->loglevel_value;
        ust_event->filter_expression = agent_event->filter_expression;
        ust_event->exclusion = agent_event->exclusion;
+end:
+       return ret;
 }
 
 static
@@ -784,7 +752,11 @@ int save_agent_events(struct config_writer *writer,
                 * (and one could wonder why they don't reuse the same
                 * structures...).
                 */
-               init_ust_event_from_agent_event(&fake_event, agent_event);
+               ret = init_ust_event_from_agent_event(&fake_event, agent_event);
+               if (ret) {
+                       rcu_read_unlock();
+                       goto end;
+               }
                ret = save_ust_event(writer, &fake_event);
                if (ret) {
                        rcu_read_unlock();
@@ -988,8 +960,8 @@ int save_ust_context(struct config_writer *writer,
                        context_type_string = get_ust_context_type_string(
                                ctx->ctx.ctx);
                        if (!context_type_string) {
-                               ERR("Unsupported UST context type.")
-                                       ret = LTTNG_ERR_INVALID;
+                               ERR("Unsupported UST context type.");
+                               ret = LTTNG_ERR_INVALID;
                                goto end;
                        }
 
This page took 0.026054 seconds and 4 git commands to generate.