ir: do not automatically generate a UUID in bt_ctf_clock_class_create()
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 8 Jun 2017 22:58:33 +0000 (18:58 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 9 Jun 2017 21:03:27 +0000 (17:03 -0400)
A clock class should be created empty, without a generated UUID which is
different each time. To maintain backward compatibility, a CTF writer
clock automatically generates a UUID on creation to set its private
clock class's UUID.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/ctf-ir/clock-class.c
lib/ctf-writer/clock.c

index 7390c66395e46297218b9c5099d55a3c72adfead..aab320f6d59885ca1eaf4a83a529e4d80e132230 100644 (file)
@@ -29,6 +29,7 @@
 #define BT_LOG_TAG "CLOCK-CLASS"
 #include <babeltrace/lib-logging-internal.h>
 
+#include <babeltrace/compat/uuid-internal.h>
 #include <babeltrace/ctf-ir/clock-class-internal.h>
 #include <babeltrace/ctf-ir/utils.h>
 #include <babeltrace/ref.h>
@@ -118,13 +119,6 @@ struct bt_ctf_clock_class *bt_ctf_clock_class_create(const char *name)
                }
        }
 
-       ret = bt_uuid_generate(clock_class->uuid);
-       if (ret) {
-               BT_LOGE_STR("Failed to generate a UUID.");
-               goto error;
-       }
-
-       clock_class->uuid_set = 1;
        BT_LOGD("Created clock class object: addr=%p, name=\"%s\"",
                clock_class, name);
        return clock_class;
index e0d52231bfc07e18ef7baf937b116f9e4f3da842..04346968f090bb343ac78f1c5ea6aba3480316a8 100644 (file)
@@ -31,6 +31,7 @@
 #include <babeltrace/ctf-ir/clock-class.h>
 #include <babeltrace/ctf-ir/clock-class-internal.h>
 #include <babeltrace/ctf-ir/utils.h>
+#include <babeltrace/compat/uuid-internal.h>
 #include <babeltrace/ref.h>
 #include <babeltrace/object-internal.h>
 #include <babeltrace/compiler-internal.h>
@@ -41,7 +42,9 @@ void bt_ctf_clock_destroy(struct bt_object *obj);
 
 struct bt_ctf_clock *bt_ctf_clock_create(const char *name)
 {
+       int ret;
        struct bt_ctf_clock *clock = NULL;
+       unsigned char cc_uuid[BABELTRACE_UUID_LEN];
 
        if (!name) {
                goto error;
@@ -59,6 +62,15 @@ struct bt_ctf_clock *bt_ctf_clock_create(const char *name)
        if (!clock->clock_class) {
                goto error;
        }
+
+       /* Automatically set clock class's UUID. */
+       ret = bt_uuid_generate(cc_uuid);
+       if (ret) {
+               goto error;
+       }
+
+       ret = bt_ctf_clock_class_set_uuid(clock->clock_class, cc_uuid);
+       assert(ret == 0);
        return clock;
 
 error:
This page took 0.025647 seconds and 4 git commands to generate.