Fix: lib: pass down API function name to some helpers
[babeltrace.git] / src / lib / trace-ir / resolve-field-path.c
index 25a5fb687561901dc747ff6c174fa9de712ebd59..51719387e97624cc3d0af638254653d87243b5be 100644 (file)
@@ -7,7 +7,7 @@
 #define BT_LOG_TAG "LIB/RESOLVE-FIELD-PATH"
 #include "lib/logging.h"
 
-#include "lib/assert-pre.h"
+#include "lib/assert-cond.h"
 #include "common/assert.h"
 #include <babeltrace2/trace-ir/field-path.h>
 #include <limits.h>
@@ -155,7 +155,7 @@ end:
        return field_path;
 }
 
-BT_ASSERT_PRE_DEV_FUNC
+BT_ASSERT_COND_DEV_FUNC
 static inline
 bool target_is_before_source(struct bt_field_path *src_field_path,
                struct bt_field_path *tgt_field_path)
@@ -199,7 +199,7 @@ end:
        return is_valid;
 }
 
-BT_ASSERT_PRE_DEV_FUNC
+BT_ASSERT_COND_DEV_FUNC
 static inline
 struct bt_field_class *borrow_root_field_class(
                struct bt_resolve_field_path_context *ctx, enum bt_field_path_scope scope)
@@ -220,7 +220,7 @@ struct bt_field_class *borrow_root_field_class(
        return NULL;
 }
 
-BT_ASSERT_PRE_DEV_FUNC
+BT_ASSERT_COND_DEV_FUNC
 static inline
 struct bt_field_class *borrow_child_field_class(
                struct bt_field_class *parent_fc,
@@ -257,7 +257,7 @@ struct bt_field_class *borrow_child_field_class(
        return child_fc;
 }
 
-BT_ASSERT_PRE_DEV_FUNC
+BT_ASSERT_COND_DEV_FUNC
 static inline
 bool target_field_path_in_different_scope_has_struct_fc_only(
                struct bt_field_path *src_field_path,
@@ -297,7 +297,7 @@ end:
        return is_valid;
 }
 
-BT_ASSERT_PRE_DEV_FUNC
+BT_ASSERT_COND_DEV_FUNC
 static inline
 bool lca_is_structure_field_class(struct bt_field_path *src_field_path,
                struct bt_field_path *tgt_field_path,
@@ -353,7 +353,7 @@ end:
        return is_valid;
 }
 
-BT_ASSERT_PRE_DEV_FUNC
+BT_ASSERT_COND_DEV_FUNC
 static inline
 bool lca_to_target_has_struct_fc_only(struct bt_field_path *src_field_path,
                struct bt_field_path *tgt_field_path,
@@ -416,7 +416,7 @@ end:
        return is_valid;
 }
 
-BT_ASSERT_PRE_DEV_FUNC
+BT_ASSERT_COND_DEV_FUNC
 static inline
 bool field_path_is_valid(struct bt_field_class *src_fc,
                struct bt_field_class *tgt_fc,
@@ -429,14 +429,14 @@ bool field_path_is_valid(struct bt_field_class *src_fc,
                tgt_fc, ctx);
 
        if (!src_field_path) {
-               BT_ASSERT_PRE_DEV_MSG("Cannot find requesting field class in "
+               BT_ASSERT_COND_DEV_MSG("Cannot find requesting field class in "
                        "resolving context: %!+F", src_fc);
                is_valid = false;
                goto end;
        }
 
        if (!tgt_field_path) {
-               BT_ASSERT_PRE_DEV_MSG("Cannot find target field class in "
+               BT_ASSERT_COND_DEV_MSG("Cannot find target field class in "
                        "resolving context: %!+F", tgt_fc);
                is_valid = false;
                goto end;
@@ -444,7 +444,7 @@ bool field_path_is_valid(struct bt_field_class *src_fc,
 
        /* Target must be before source */
        if (!target_is_before_source(src_field_path, tgt_field_path)) {
-               BT_ASSERT_PRE_DEV_MSG("Target field class is located after "
+               BT_ASSERT_COND_DEV_MSG("Target field class is located after "
                        "requesting field class: %![req-fc-]+F, %![tgt-fc-]+F",
                        src_fc, tgt_fc);
                is_valid = false;
@@ -457,7 +457,7 @@ bool field_path_is_valid(struct bt_field_class *src_fc,
         */
        if (!target_field_path_in_different_scope_has_struct_fc_only(
                        src_field_path, tgt_field_path, ctx)) {
-               BT_ASSERT_PRE_DEV_MSG("Target field class is located in a "
+               BT_ASSERT_COND_DEV_MSG("Target field class is located in a "
                        "different scope than requesting field class, "
                        "but within an array or a variant field class: "
                        "%![req-fc-]+F, %![tgt-fc-]+F",
@@ -468,7 +468,7 @@ bool field_path_is_valid(struct bt_field_class *src_fc,
 
        /* Same scope: LCA must be a structure field class */
        if (!lca_is_structure_field_class(src_field_path, tgt_field_path, ctx)) {
-               BT_ASSERT_PRE_DEV_MSG("Lowest common ancestor of target and "
+               BT_ASSERT_COND_DEV_MSG("Lowest common ancestor of target and "
                        "requesting field classes is not a structure field class: "
                        "%![req-fc-]+F, %![tgt-fc-]+F",
                        src_fc, tgt_fc);
@@ -479,7 +479,7 @@ bool field_path_is_valid(struct bt_field_class *src_fc,
        /* Same scope: path from LCA to target has no array/variant FTs */
        if (!lca_to_target_has_struct_fc_only(src_field_path, tgt_field_path,
                        ctx)) {
-               BT_ASSERT_PRE_DEV_MSG("Path from lowest common ancestor of target "
+               BT_ASSERT_COND_DEV_MSG("Path from lowest common ancestor of target "
                        "and requesting field classes to target field class "
                        "contains an array or a variant field class: "
                        "%![req-fc-]+F, %![tgt-fc-]+F", src_fc, tgt_fc);
@@ -496,9 +496,11 @@ end:
 static
 struct bt_field_path *resolve_field_path(struct bt_field_class *src_fc,
                struct bt_field_class *tgt_fc,
-               struct bt_resolve_field_path_context *ctx)
+               struct bt_resolve_field_path_context *ctx,
+               const char *api_func)
 {
-       BT_ASSERT_PRE_DEV(field_path_is_valid(src_fc, tgt_fc, ctx),
+       BT_ASSERT_PRE_DEV_FROM_FUNC(api_func, "valid-field-class",
+               field_path_is_valid(src_fc, tgt_fc, ctx),
                "Invalid target field class: %![req-fc-]+F, %![tgt-fc-]+F",
                src_fc, tgt_fc);
        return find_field_class_in_ctx(tgt_fc, ctx);
@@ -506,7 +508,8 @@ struct bt_field_path *resolve_field_path(struct bt_field_class *src_fc,
 
 BT_HIDDEN
 int bt_resolve_field_paths(struct bt_field_class *fc,
-               struct bt_resolve_field_path_context *ctx)
+               struct bt_resolve_field_path_context *ctx,
+               const char *api_func)
 {
        int ret = 0;
 
@@ -520,7 +523,7 @@ int bt_resolve_field_paths(struct bt_field_class *fc,
                BT_ASSERT(opt_fc->selector_fc);
                BT_ASSERT(!opt_fc->selector_field_path);
                opt_fc->selector_field_path = resolve_field_path(
-                       fc, opt_fc->selector_fc, ctx);
+                       fc, opt_fc->selector_fc, ctx, __func__);
                if (!opt_fc->selector_field_path) {
                        ret = -1;
                        goto end;
@@ -531,7 +534,7 @@ int bt_resolve_field_paths(struct bt_field_class *fc,
                BT_ASSERT(dyn_array_fc->length_fc);
                BT_ASSERT(!dyn_array_fc->length_field_path);
                dyn_array_fc->length_field_path = resolve_field_path(
-                       fc, dyn_array_fc->length_fc, ctx);
+                       fc, dyn_array_fc->length_fc, ctx, __func__);
                if (!dyn_array_fc->length_field_path) {
                        ret = -1;
                        goto end;
@@ -545,7 +548,8 @@ int bt_resolve_field_paths(struct bt_field_class *fc,
                        BT_ASSERT(!var_fc->selector_field_path);
                        var_fc->selector_field_path =
                                resolve_field_path(fc,
-                                       (void *) var_fc->selector_fc, ctx);
+                                       (void *) var_fc->selector_fc, ctx,
+                                       __func__);
                        if (!var_fc->selector_field_path) {
                                ret = -1;
                                goto end;
@@ -557,7 +561,7 @@ int bt_resolve_field_paths(struct bt_field_class *fc,
        if (bt_field_class_type_is(fc->type, BT_FIELD_CLASS_TYPE_OPTION)) {
                struct bt_field_class_option *opt_fc = (void *) fc;
 
-               ret = bt_resolve_field_paths(opt_fc->content_fc, ctx);
+               ret = bt_resolve_field_paths(opt_fc->content_fc, ctx, api_func);
        } else if (fc->type == BT_FIELD_CLASS_TYPE_STRUCTURE ||
                        bt_field_class_type_is(fc->type,
                                BT_FIELD_CLASS_TYPE_VARIANT)) {
@@ -569,7 +573,8 @@ int bt_resolve_field_paths(struct bt_field_class *fc,
                        struct bt_named_field_class *named_fc =
                                container_fc->named_fcs->pdata[i];
 
-                       ret = bt_resolve_field_paths(named_fc->fc, ctx);
+                       ret = bt_resolve_field_paths(named_fc->fc, ctx,
+                               api_func);
                        if (ret) {
                                goto end;
                        }
@@ -578,7 +583,8 @@ int bt_resolve_field_paths(struct bt_field_class *fc,
                        BT_FIELD_CLASS_TYPE_ARRAY)) {
                struct bt_field_class_array *array_fc = (void *) fc;
 
-               ret = bt_resolve_field_paths(array_fc->element_fc, ctx);
+               ret = bt_resolve_field_paths(array_fc->element_fc, ctx,
+                       api_func);
        }
 
 end:
This page took 0.026326 seconds and 4 git commands to generate.