lttng-sessiond: remove goto in ust_metadata_channel_statedump
[lttng-tools.git] / src / bin / lttng-sessiond / ust-metadata.cpp
index f5c5e7a2136c9cb2a533e4f90a6f1cfa08aef811..d08cb40ae7f10ade8a8add223997a2e7aa884bed 100644 (file)
 #include "ust-clock.hpp"
 #include "ust-app.hpp"
 
-#ifndef max_t
-#define max_t(type, a, b)      ((type) ((a) > (b) ? (a) : (b)))
-#endif
-
 #define NR_CLOCK_OFFSET_SAMPLES                10
 
 struct offset_sample {
@@ -69,7 +65,7 @@ ssize_t metadata_reserve(struct ust_registry_session *session, size_t len)
                char *newptr;
 
                new_alloc_len =
-                       max_t(size_t, 1U << get_count_order(new_alloc_len), old_alloc_len << 1);
+                       std::max<size_t>(1U << get_count_order(new_alloc_len), old_alloc_len << 1);
                newptr = (char *) realloc(session->metadata, new_alloc_len);
                if (!newptr)
                        return -ENOMEM;
@@ -903,7 +899,7 @@ end:
 int ust_metadata_channel_statedump(struct ust_registry_session *session,
                struct ust_registry_channel *chan)
 {
-       int ret = 0;
+       int ret;
 
        /* Don't dump metadata events */
        if (chan->chan_id == -1U)
@@ -922,37 +918,40 @@ int ust_metadata_channel_statedump(struct ust_registry_session *session,
                        "struct event_header_compact" :
                        "struct event_header_large");
        if (ret) {
-               goto end;
+               return ret;
        }
 
        if (chan->ctx_fields) {
                ret = lttng_metadata_printf(session,
                        "       event.context := struct {\n");
                if (ret) {
-                       goto end;
+                       return ret;
                }
        }
        ret = _lttng_context_metadata_statedump(session,
                chan->nr_ctx_fields,
                chan->ctx_fields);
        if (ret) {
-               goto end;
+               return ret;
        }
        if (chan->ctx_fields) {
                ret = lttng_metadata_printf(session,
                        "       };\n");
                if (ret) {
-                       goto end;
+                       return ret;
                }
        }
 
        ret = lttng_metadata_printf(session,
                "};\n\n");
+       if (ret) {
+               return ret;
+       }
+
        /* Flag success of metadata dump. */
        chan->metadata_dumped = 1;
 
-end:
-       return ret;
+       return 0;
 }
 
 static
This page took 0.024268 seconds and 4 git commands to generate.