Use uuid_to_str() when formatting metadata
[lttng-tools.git] / src / bin / lttng-sessiond / ust-metadata.c
index c97013f438a88df9b9d7ccf1205761731261860b..a657f7c5d3d26b62472e66ecef3f188e987ee121 100644 (file)
@@ -28,6 +28,7 @@
 #include <unistd.h>
 #include <inttypes.h>
 #include <common/common.h>
+#include <common/time.h>
 
 #include "ust-registry.h"
 #include "ust-clock.h"
@@ -37,7 +38,6 @@
 #define max_t(type, a, b)      ((type) ((a) > (b) ? (a) : (b)))
 #endif
 
-#define NSEC_PER_SEC                   1000000000ULL
 #define NR_CLOCK_OFFSET_SAMPLES                10
 
 struct offset_sample {
@@ -74,7 +74,6 @@ int fls(unsigned int x)
                r -= 2;
        }
        if (!(x & 0x80000000U)) {
-               x <<= 1;
                r -= 1;
        }
        return r;
@@ -300,38 +299,53 @@ int ust_metadata_enum_statedump(struct ust_registry_session *session,
                                goto end;
                        }
                }
-               ret = lttng_metadata_printf(session,
-                               "\" = ");
+               ret = lttng_metadata_printf(session, "\"");
                if (ret) {
                        goto end;
                }
 
-               if (entry->start.signedness) {
-                       ret = lttng_metadata_printf(session,
-                               "%lld", (long long) entry->start.value);
+               if (entry->u.extra.options &
+                               USTCTL_UST_ENUM_ENTRY_OPTION_IS_AUTO) {
+                       ret = lttng_metadata_printf(session, ",\n");
+                       if (ret) {
+                               goto end;
+                       }
                } else {
                        ret = lttng_metadata_printf(session,
-                               "%llu", entry->start.value);
-               }
-               if (ret) {
-                       goto end;
-               }
+                                       " = ");
+                       if (ret) {
+                               goto end;
+                       }
 
-               if (entry->start.signedness == entry->end.signedness &&
-                               entry->start.value == entry->end.value) {
-                       ret = lttng_metadata_printf(session,
-                               ",\n");
-               } else {
-                       if (entry->end.signedness) {
+                       if (entry->start.signedness) {
                                ret = lttng_metadata_printf(session,
-                                       " ... %lld,\n", (long long) entry->end.value);
+                                       "%lld", (long long) entry->start.value);
                        } else {
                                ret = lttng_metadata_printf(session,
-                                       " ... %llu,\n", entry->end.value);
+                                       "%llu", entry->start.value);
+                       }
+                       if (ret) {
+                               goto end;
+                       }
+
+                       if (entry->start.signedness == entry->end.signedness &&
+                                       entry->start.value ==
+                                               entry->end.value) {
+                               ret = lttng_metadata_printf(session, ",\n");
+                       } else {
+                               if (entry->end.signedness) {
+                                       ret = lttng_metadata_printf(session,
+                                               " ... %lld,\n",
+                                               (long long) entry->end.value);
+                               } else {
+                                       ret = lttng_metadata_printf(session,
+                                               " ... %llu,\n",
+                                               entry->end.value);
+                               }
+                       }
+                       if (ret) {
+                               goto end;
                        }
-               }
-               if (ret) {
-                       goto end;
                }
        }
        nesting--;
@@ -389,6 +403,9 @@ int _lttng_variant_statedump(struct ust_registry_session *session,
        }
        sanitize_ctf_identifier(identifier, variant->name);
        ret = print_tabs(session, nesting);
+       if (ret) {
+               goto end;
+       }
        ret = lttng_metadata_printf(session,
                        "} _%s;\n",
                        identifier);
@@ -804,7 +821,7 @@ int measure_single_clock_offset(struct offset_sample *sample)
        int ret;
 
        monotonic[0] = trace_clock_read64();
-       ret = clock_gettime(CLOCK_REALTIME, &rts);
+       ret = lttng_clock_gettime(CLOCK_REALTIME, &rts);
        if (ret < 0) {
                return ret;
        }
@@ -860,7 +877,6 @@ int ust_metadata_session_statedump(struct ust_registry_session *session,
                uint32_t major,
                uint32_t minor)
 {
-       unsigned char *uuid_c;
        char uuid_s[UUID_STR_LEN],
                clock_uuid_s[UUID_STR_LEN];
        int ret = 0;
@@ -868,14 +884,7 @@ int ust_metadata_session_statedump(struct ust_registry_session *session,
 
        assert(session);
 
-       uuid_c = session->uuid;
-
-       snprintf(uuid_s, sizeof(uuid_s),
-               "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-               uuid_c[0], uuid_c[1], uuid_c[2], uuid_c[3],
-               uuid_c[4], uuid_c[5], uuid_c[6], uuid_c[7],
-               uuid_c[8], uuid_c[9], uuid_c[10], uuid_c[11],
-               uuid_c[12], uuid_c[13], uuid_c[14], uuid_c[15]);
+       lttng_uuid_to_str(session->uuid, uuid_s);
 
        /* For crash ABI */
        ret = lttng_metadata_printf(session,
This page took 0.026667 seconds and 5 git commands to generate.