Fix: add_clock_classes(): do not add existing clock classes
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 19 Jun 2017 22:41:50 +0000 (18:41 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 6 Jul 2017 20:04:38 +0000 (16:04 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
plugins/lttng-utils/copy.c

index eca816851018849c0c1fe8d7d7161aba0e67734f..52d5b4899b7b3f63abaa10ba1da4e4963809eb11 100644 (file)
@@ -1130,6 +1130,7 @@ int add_clock_classes(FILE *err, struct bt_ctf_trace *writer_trace,
        for (i = 0; i < clock_class_count; i++) {
                struct bt_ctf_clock_class *clock_class =
                        bt_ctf_trace_get_clock_class_by_index(trace, i);
+               struct bt_ctf_clock_class *existing_clock_class = NULL;
 
                if (!clock_class) {
                        fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
@@ -1137,6 +1138,14 @@ int add_clock_classes(FILE *err, struct bt_ctf_trace *writer_trace,
                        goto error;
                }
 
+               existing_clock_class = bt_ctf_trace_get_clock_class_by_name(
+                       writer_trace, bt_ctf_clock_class_get_name(clock_class));
+               bt_put(existing_clock_class);
+               if (existing_clock_class) {
+                       bt_put(clock_class);
+                       continue;
+               }
+
                ret = bt_ctf_trace_add_clock_class(writer_trace, clock_class);
                BT_PUT(clock_class);
                if (ret != 0) {
This page took 0.026546 seconds and 4 git commands to generate.