Fix: src.ctf.fs: Not resolving event common ctx
[babeltrace.git] / src / plugins / ctf / common / metadata / ctf-meta-resolve.c
index 630f14ed5e780ab11100c346f6df187260fa9d15..55143f34db0c96b8173492d0b69816e29b2a0f9b 100644 (file)
@@ -23,6 +23,7 @@
 #include "common/assert.h"
 #include "common/common.h"
 #include <glib.h>
+#include <stdbool.h>
 #include <stdint.h>
 #include <string.h>
 #include <inttypes.h>
@@ -181,15 +182,10 @@ size_t field_class_stack_size(field_class_stack *stack)
 static
 struct field_class_stack_frame *field_class_stack_peek(field_class_stack *stack)
 {
-       struct field_class_stack_frame *entry = NULL;
+       BT_ASSERT(stack);
+       BT_ASSERT(!field_class_stack_empty(stack));
 
-       if (!stack || field_class_stack_empty(stack)) {
-               goto end;
-       }
-
-       entry = g_ptr_array_index(stack, stack->len - 1);
-end:
-       return entry;
+       return g_ptr_array_index(stack, stack->len - 1);
 }
 
 /*
@@ -199,16 +195,10 @@ static
 struct field_class_stack_frame *field_class_stack_at(field_class_stack *stack,
                size_t index)
 {
-       struct field_class_stack_frame *entry = NULL;
-
-       if (!stack || index >= stack->len) {
-               goto end;
-       }
-
-       entry = g_ptr_array_index(stack, index);
+       BT_ASSERT(stack);
+       BT_ASSERT(index < stack->len);
 
-end:
-       return entry;
+       return g_ptr_array_index(stack, index);
 }
 
 /*
@@ -250,7 +240,7 @@ struct ctf_field_class *borrow_class_from_ctx(struct resolve_context *ctx,
        case CTF_SCOPE_EVENT_PAYLOAD:
                return ctx->scopes.event_payload;
        default:
-               abort();
+               bt_common_abort();
        }
 
        return NULL;
@@ -530,7 +520,7 @@ int absolute_ptokens_to_field_path(GList *ptokens,
                break;
 
        default:
-               abort();
+               bt_common_abort();
        }
 
        /* Skip absolute path tokens */
@@ -691,7 +681,7 @@ int pathstr_to_field_path(const char *pathstr,
        if (BT_LOG_ON_TRACE && ret == 0) {
                GString *field_path_pretty = ctf_field_path_string(field_path);
                const char *field_path_pretty_str =
-                       field_path_pretty ? field_path_pretty->str : NULL;
+                       field_path_pretty ? field_path_pretty->str : "(null)";
 
                BT_COMP_LOGD("Found field path: path=\"%s\", field-path=\"%s\"",
                        pathstr, field_path_pretty_str);
@@ -770,6 +760,7 @@ void get_ctx_stack_field_path(struct resolve_context *ctx,
  * Returns the index of the lowest common ancestor of two field path
  * objects having the same root scope.
  */
+static
 int64_t get_field_paths_lca_index(struct ctf_field_path *field_path1,
                struct ctf_field_path *field_path2,
                struct resolve_context *ctx)
@@ -783,9 +774,9 @@ int64_t get_field_paths_lca_index(struct ctf_field_path *field_path1,
                GString *field_path2_pretty =
                        ctf_field_path_string(field_path2);
                const char *field_path1_pretty_str =
-                       field_path1_pretty ? field_path1_pretty->str : NULL;
+                       field_path1_pretty ? field_path1_pretty->str : "(null)";
                const char *field_path2_pretty_str =
-                       field_path2_pretty ? field_path2_pretty->str : NULL;
+                       field_path2_pretty ? field_path2_pretty->str : "(null)";
 
                BT_COMP_LOGD("Finding lowest common ancestor (LCA) between two field paths: "
                        "field-path-1=\"%s\", field-path-2=\"%s\"",
@@ -953,7 +944,7 @@ int validate_target_field_path(struct ctf_field_path *target_field_path,
                break;
        }
        default:
-               abort();
+               bt_common_abort();
        }
 
 end:
@@ -992,7 +983,7 @@ int resolve_sequence_or_variant_field_class(struct ctf_field_class *fc,
                break;
        }
        default:
-               abort();
+               bt_common_abort();
        }
 
        if (!pathstr) {
@@ -1055,7 +1046,7 @@ int resolve_sequence_or_variant_field_class(struct ctf_field_class *fc,
                break;
        }
        default:
-               abort();
+               bt_common_abort();
        }
 
 end:
@@ -1236,7 +1227,7 @@ int resolve_stream_class_field_classes(struct resolve_context *ctx,
                }
 
                ctx->scopes.event_common_context = sc->event_common_context_fc;
-               ret = resolve_root_class(CTF_SCOPE_EVENT_SPECIFIC_CONTEXT, ctx);
+               ret = resolve_root_class(CTF_SCOPE_EVENT_COMMON_CONTEXT, ctx);
                if (ret) {
                        BT_COMP_LOGE("Cannot resolve event common context field class: "
                                "ret=%d", ret);
This page took 0.026144 seconds and 4 git commands to generate.