Fix unhandled return value
[lttng-tools.git] / src / bin / lttng-sessiond / context.c
index 7fc455438fab9cc856b6b37204997a16bccf7919..19eaa714521764de1bda512bde33f6123ddfe6d0 100644 (file)
@@ -22,8 +22,8 @@
 #include <unistd.h>
 #include <urcu/list.h>
 
+#include <common/error.h>
 #include <common/sessiond-comm/sessiond-comm.h>
-#include <common/lttngerr.h>
 
 #include "context.h"
 #include "kernel.h"
@@ -174,7 +174,7 @@ static int add_uctx_to_channel(struct ltt_ust_session *usess, int domain,
                }
                break;
        default:
-               ret = LTTCOMM_NOT_IMPLEMENTED;
+               ret = LTTCOMM_UND;
                goto error;
        }
 
@@ -213,7 +213,7 @@ static int add_uctx_to_event(struct ltt_ust_session *usess, int domain,
                }
                break;
        default:
-               ret = LTTCOMM_NOT_IMPLEMENTED;
+               ret = LTTCOMM_UND;
                goto error;
        }
 
@@ -239,7 +239,41 @@ int context_kernel_add(struct ltt_kernel_session *ksession,
        struct lttng_kernel_context kctx;
 
        /* Setup kernel context structure */
-       kctx.ctx = ctx->ctx;
+       switch (ctx->ctx) {
+       case LTTNG_EVENT_CONTEXT_PID:
+               kctx.ctx = LTTNG_KERNEL_CONTEXT_PID;
+               break;
+       case LTTNG_EVENT_CONTEXT_PERF_COUNTER:
+               kctx.ctx = LTTNG_KERNEL_CONTEXT_PERF_COUNTER;
+               break;
+       case LTTNG_EVENT_CONTEXT_PROCNAME:
+               kctx.ctx = LTTNG_KERNEL_CONTEXT_PROCNAME;
+               break;
+       case LTTNG_EVENT_CONTEXT_PRIO:
+               kctx.ctx = LTTNG_KERNEL_CONTEXT_PRIO;
+               break;
+       case LTTNG_EVENT_CONTEXT_NICE:
+               kctx.ctx = LTTNG_KERNEL_CONTEXT_NICE;
+               break;
+       case LTTNG_EVENT_CONTEXT_VPID:
+               kctx.ctx = LTTNG_KERNEL_CONTEXT_VPID;
+               break;
+       case LTTNG_EVENT_CONTEXT_TID:
+               kctx.ctx = LTTNG_KERNEL_CONTEXT_TID;
+               break;
+       case LTTNG_EVENT_CONTEXT_VTID:
+               kctx.ctx = LTTNG_KERNEL_CONTEXT_VTID;
+               break;
+       case LTTNG_EVENT_CONTEXT_PPID:
+               kctx.ctx = LTTNG_KERNEL_CONTEXT_PPID;
+               break;
+       case LTTNG_EVENT_CONTEXT_VPPID:
+               kctx.ctx = LTTNG_KERNEL_CONTEXT_VPPID;
+               break;
+       default:
+               return LTTCOMM_KERN_CONTEXT_FAIL;
+       }
+
        kctx.u.perf_counter.type = ctx->u.perf_counter.type;
        kctx.u.perf_counter.config = ctx->u.perf_counter.config;
        strncpy(kctx.u.perf_counter.name, ctx->u.perf_counter.name,
@@ -279,7 +313,7 @@ int context_ust_add(struct ltt_ust_session *usess, int domain,
                char *channel_name)
 {
        int ret = LTTCOMM_OK, have_event = 0;
-       struct lttng_ht_iter iter, uiter;
+       struct lttng_ht_iter iter;
        struct lttng_ht *chan_ht;
        struct ltt_ust_channel *uchan = NULL;
        struct ltt_ust_event *uevent = NULL;
@@ -292,11 +326,13 @@ int context_ust_add(struct ltt_ust_session *usess, int domain,
        case LTTNG_DOMAIN_UST:
                chan_ht = usess->domain_global.channels;
                break;
+#if 0
        case LTTNG_DOMAIN_UST_EXEC_NAME:
        case LTTNG_DOMAIN_UST_PID:
        case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
+#endif
        default:
-               ret = LTTCOMM_NOT_IMPLEMENTED;
+               ret = LTTCOMM_UND;
                goto error;
        }
 
@@ -353,17 +389,6 @@ int context_ust_add(struct ltt_ust_session *usess, int domain,
                                ERR("Context added to channel %s failed", uchan->name);
                                continue;
                        }
-
-                       /* For all events in channel */
-                       cds_lfht_for_each_entry(uchan->events->ht, &uiter.iter, uevent,
-                                       node.node) {
-                               ret = add_uctx_to_event(usess, domain, uchan, uevent, ctx);
-                               if (ret < 0) {
-                                       ERR("Context add to event %s in channel %s failed",
-                                                       uevent->attr.name, uchan->name);
-                                       continue;
-                               }
-                       }
                }
        }
 
This page took 0.024058 seconds and 4 git commands to generate.