From: Philippe Proulx Date: Thu, 8 Jun 2017 22:58:33 +0000 (-0400) Subject: ir: do not automatically generate a UUID in bt_ctf_clock_class_create() X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=75c3fca1fc5b7fb625894a670b6d814d106161b6;p=deliverable%2Fbabeltrace.git ir: do not automatically generate a UUID in bt_ctf_clock_class_create() 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 Signed-off-by: Jérémie Galarneau --- diff --git a/lib/ctf-ir/clock-class.c b/lib/ctf-ir/clock-class.c index 7390c6639..aab320f6d 100644 --- a/lib/ctf-ir/clock-class.c +++ b/lib/ctf-ir/clock-class.c @@ -29,6 +29,7 @@ #define BT_LOG_TAG "CLOCK-CLASS" #include +#include #include #include #include @@ -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; diff --git a/lib/ctf-writer/clock.c b/lib/ctf-writer/clock.c index e0d52231b..04346968f 100644 --- a/lib/ctf-writer/clock.c +++ b/lib/ctf-writer/clock.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -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: