From 75c3fca1fc5b7fb625894a670b6d814d106161b6 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 8 Jun 2017 18:58:33 -0400 Subject: [PATCH] ir: do not automatically generate a UUID in bt_ctf_clock_class_create() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- lib/ctf-ir/clock-class.c | 8 +------- lib/ctf-writer/clock.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/ctf-ir/clock-class.c b/lib/ctf-ir/clock-class.c index 7390c663..aab320f6 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 e0d52231..04346968 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: -- 2.34.1