Check for context name duplicata
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 14 Jul 2011 17:46:21 +0000 (13:46 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 14 Jul 2011 17:46:21 +0000 (13:46 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
12 files changed:
ltt-context.c
ltt-events.h
lttng-context-comm.c
lttng-context-nice.c
lttng-context-perf-counters.c
lttng-context-pid.c
lttng-context-ppid.c
lttng-context-prio.c
lttng-context-tid.c
lttng-context-vpid.c
lttng-context-vppid.c
lttng-context-vtid.c

index 634694b968d4c06f6cf5066b684c80efc10d68d9..6c3890c3e4a7ba46d2c6f320610a069edbf7dbcd 100644 (file)
 #include "ltt-events.h"
 #include "ltt-tracer.h"
 
+int lttng_find_context(struct lttng_ctx *ctx, const char *name)
+{
+       unsigned int i;
+
+       for (i = 0; i < ctx->nr_fields; i++) {
+               if (!strcmp(ctx->fields[i].event_field.name, name))
+                       return 1;
+       }
+       return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_find_context);
+
 struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx_p)
 {
        struct lttng_ctx_field *field;
index 10015ad6150cb7404b9bfe39797e3848c969d7a2..1307c36b6d0b8b7ca56014a5cb3f3078a283f3e0 100644 (file)
@@ -284,6 +284,7 @@ void ltt_event_put(const struct lttng_event_desc *desc);
 int ltt_probes_init(void);
 void ltt_probes_exit(void);
 struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx);
+int lttng_find_context(struct lttng_ctx *ctx, const char *name);
 void lttng_remove_context_field(struct lttng_ctx **ctx,
                                struct lttng_ctx_field *field);
 void lttng_destroy_context(struct lttng_ctx *ctx);
index ede3f51a0d4bd9ffd9568d75a28e1fc4ebc75668..beea83ffc14e471769a7c34da63591adb2a63fd4 100644 (file)
@@ -45,6 +45,10 @@ int lttng_add_comm_to_ctx(struct lttng_ctx **ctx)
        field = lttng_append_context(ctx);
        if (!field)
                return -ENOMEM;
+       if (lttng_find_context(*ctx, "comm")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
        field->event_field.name = "comm";
        field->event_field.type.atype = atype_array;
        field->event_field.type.u.array.elem_type.atype = atype_integer;
index bfe688ef1084c1b1c8a327f383ef01dbf1281240..9b99b54924650b1da1b510bb4255da2380d3f193 100644 (file)
@@ -44,6 +44,10 @@ int lttng_add_nice_to_ctx(struct lttng_ctx **ctx)
        field = lttng_append_context(ctx);
        if (!field)
                return -ENOMEM;
+       if (lttng_find_context(*ctx, "nice")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
        field->event_field.name = "nice";
        field->event_field.type.atype = atype_integer;
        field->event_field.type.u.basic.integer.size = sizeof(int) * CHAR_BIT;
index 5327e6ef06956707a914d15c3d56e9924291d06b..2f7132fbf26bf8db8aa9897fbfcee73cbc97e143 100644 (file)
@@ -170,6 +170,10 @@ int lttng_add_perf_counter_to_ctx(uint32_t type,
                ret = -ENOMEM;
                goto append_context_error;
        }
+       if (lttng_find_context(*ctx, name_alloc))  {
+               ret = -EEXIST;
+               goto find_error;
+       }
 
 #ifdef CONFIG_HOTPLUG_CPU
        field->u.perf_counter.nb.notifier_call =
@@ -217,6 +221,7 @@ counter_error:
 #ifdef CONFIG_HOTPLUG_CPU
        unregister_cpu_notifier(&field->u.perf_counter.nb);
 #endif
+find_error:
        lttng_remove_context_field(ctx, field);
 append_context_error:
        kfree(name_alloc);
index ee2c4f0f5c36ebb116cfa66a8ec46658cc217920..698b242245a28b6e38484f65f21f129e53ab9774 100644 (file)
@@ -44,6 +44,10 @@ int lttng_add_pid_to_ctx(struct lttng_ctx **ctx)
        field = lttng_append_context(ctx);
        if (!field)
                return -ENOMEM;
+       if (lttng_find_context(*ctx, "pid")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
        field->event_field.name = "pid";
        field->event_field.type.atype = atype_integer;
        field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
index 9f647ab1a079eac1066057cebefea2205a7b8ee7..738f7e6882d518d95b2ebe559ede4e683363bbf9 100644 (file)
@@ -47,6 +47,10 @@ int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx)
        field = lttng_append_context(ctx);
        if (!field)
                return -ENOMEM;
+       if (lttng_find_context(*ctx, "ppid")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
        field->event_field.name = "ppid";
        field->event_field.type.atype = atype_integer;
        field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
index 842717ca7c74def7f4368aae807083c5b2b34666..ad1c42f43ef5d56ed638ec76087ff1048b2b2992 100644 (file)
@@ -64,6 +64,10 @@ int lttng_add_prio_to_ctx(struct lttng_ctx **ctx)
        field = lttng_append_context(ctx);
        if (!field)
                return -ENOMEM;
+       if (lttng_find_context(*ctx, "prio")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
        field->event_field.name = "prio";
        field->event_field.type.atype = atype_integer;
        field->event_field.type.u.basic.integer.size = sizeof(int) * CHAR_BIT;
index f207d986af5bbf15f979d27c254701d35b5c7e8b..d5ccdb635c406d81d60313fad5ecb49945130eec 100644 (file)
@@ -44,6 +44,10 @@ int lttng_add_tid_to_ctx(struct lttng_ctx **ctx)
        field = lttng_append_context(ctx);
        if (!field)
                return -ENOMEM;
+       if (lttng_find_context(*ctx, "tid")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
        field->event_field.name = "tid";
        field->event_field.type.atype = atype_integer;
        field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
index c99010cf80a60ba71e7a937547cabe1059f661c1..f12eb97efebe25bbae9355320a3d9e5a16da0577 100644 (file)
@@ -44,6 +44,10 @@ int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx)
        field = lttng_append_context(ctx);
        if (!field)
                return -ENOMEM;
+       if (lttng_find_context(*ctx, "vpid")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
        field->event_field.name = "vpid";
        field->event_field.type.atype = atype_integer;
        field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
index d55e12db6b2541afd1d7da7274fdb6385f326088..4abf784613afebf844f9be3ed92946519dbff31f 100644 (file)
@@ -47,6 +47,10 @@ int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx)
        field = lttng_append_context(ctx);
        if (!field)
                return -ENOMEM;
+       if (lttng_find_context(*ctx, "vppid")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
        field->event_field.name = "vppid";
        field->event_field.type.atype = atype_integer;
        field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
index 522d2bd6112b8bb74c9be53ea172324f7d1363f4..c428911ef98aff76bdb822dc72e494febcf41b64 100644 (file)
@@ -44,6 +44,10 @@ int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx)
        field = lttng_append_context(ctx);
        if (!field)
                return -ENOMEM;
+       if (lttng_find_context(*ctx, "vtid")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
        field->event_field.name = "vtid";
        field->event_field.type.atype = atype_integer;
        field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
This page took 0.035676 seconds and 4 git commands to generate.