- int ret = 0;
- struct ctf_field_path ctx_field_path;
- uint64_t target_field_path_len = target_field_path->path->len;
- int64_t lca_index;
-
- /* Get context field path */
- ctf_field_path_init(&ctx_field_path);
- get_ctx_stack_field_path(ctx, &ctx_field_path);
-
- /*
- * Make sure the target is not a root.
- */
- if (target_field_path_len == 0) {
- _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Target field path's length is 0 (targeting the root).");
- ret = -1;
- goto end;
- }
-
- /*
- * Make sure the root of the target field path is not located
- * after the context field path's root.
- */
- if (target_field_path->root > ctx_field_path.root) {
- _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Target field class is located after source field class: "
- "target-root=%s, source-root=%s",
- ctf_scope_string(target_field_path->root),
- ctf_scope_string(ctx_field_path.root));
- ret = -1;
- goto end;
- }
-
- if (target_field_path->root == ctx_field_path.root) {
- int64_t target_index, ctx_index;
-
- /*
- * Find the index of the lowest common ancestor of both field
- * paths.
- */
- lca_index = get_field_paths_lca_index(target_field_path,
- &ctx_field_path, ctx);
- if (lca_index < 0) {
- _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot get least common ancestor.");
- ret = -1;
- goto end;
- }
-
- /*
- * Make sure the target field path is located before the
- * context field path.
- */
- target_index = ctf_field_path_borrow_index_by_index(
- target_field_path, (uint64_t) lca_index);
- ctx_index = ctf_field_path_borrow_index_by_index(
- &ctx_field_path, (uint64_t) lca_index);
-
- if (target_index >= ctx_index) {
- _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Target field class's index is greater than or equal to source field class's index in LCA: "
- "lca-index=%" PRId64 ", "
- "target-index=%" PRId64 ", "
- "source-index=%" PRId64,
- lca_index, target_index, ctx_index);
- ret = -1;
- goto end;
- }
- }
-
- /*
- * Make sure the target class has the right class and properties.
- */
- switch (ctx->cur_fc->type) {
- case CTF_FIELD_CLASS_TYPE_VARIANT:
- if (target_fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
- _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Variant field class's tag field class is not an enumeration field class: "
- "tag-fc-addr=%p, tag-fc-id=%d",
- target_fc, target_fc->type);
- ret = -1;
- goto end;
- }
- break;
- case CTF_FIELD_CLASS_TYPE_SEQUENCE:
- {
- struct ctf_field_class_int *int_fc = ctf_field_class_as_int(target_fc);
-
- if (target_fc->type != CTF_FIELD_CLASS_TYPE_INT &&
- target_fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
- _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Sequence field class's length field class is not an unsigned integer field class: "
- "length-fc-addr=%p, length-fc-id=%d",
- target_fc, target_fc->type);
- ret = -1;
- goto end;
- }
-
- if (int_fc->is_signed) {
- _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Sequence field class's length field class is not an unsigned integer field class: "
- "length-fc-addr=%p, length-fc-id=%d",
- target_fc, target_fc->type);
- ret = -1;
- goto end;
- }
- break;
- }
- default:
- bt_common_abort();
- }
+ int ret = 0;
+ struct ctf_field_path ctx_field_path;
+ uint64_t target_field_path_len = target_field_path->path->len;
+ int64_t lca_index;
+
+ /* Get context field path */
+ ctf_field_path_init(&ctx_field_path);
+ get_ctx_stack_field_path(ctx, &ctx_field_path);
+
+ /*
+ * Make sure the target is not a root.
+ */
+ if (target_field_path_len == 0) {
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(
+ "Target field path's length is 0 (targeting the root).");
+ ret = -1;
+ goto end;
+ }
+
+ /*
+ * Make sure the root of the target field path is not located
+ * after the context field path's root.
+ */
+ if (target_field_path->root > ctx_field_path.root) {
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(
+ "Target field class is located after source field class: "
+ "target-root=%s, source-root=%s",
+ ctf_scope_string(target_field_path->root), ctf_scope_string(ctx_field_path.root));
+ ret = -1;
+ goto end;
+ }
+
+ if (target_field_path->root == ctx_field_path.root) {
+ int64_t target_index, ctx_index;
+
+ /*
+ * Find the index of the lowest common ancestor of both field
+ * paths.
+ */
+ lca_index = get_field_paths_lca_index(target_field_path, &ctx_field_path, ctx);
+ if (lca_index < 0) {
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Cannot get least common ancestor.");
+ ret = -1;
+ goto end;
+ }
+
+ /*
+ * Make sure the target field path is located before the
+ * context field path.
+ */
+ target_index =
+ ctf_field_path_borrow_index_by_index(target_field_path, (uint64_t) lca_index);
+ ctx_index = ctf_field_path_borrow_index_by_index(&ctx_field_path, (uint64_t) lca_index);
+
+ if (target_index >= ctx_index) {
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(
+ "Target field class's index is greater than or equal to source field class's index in LCA: "
+ "lca-index=%" PRId64 ", "
+ "target-index=%" PRId64 ", "
+ "source-index=%" PRId64,
+ lca_index, target_index, ctx_index);
+ ret = -1;
+ goto end;
+ }
+ }
+
+ /*
+ * Make sure the target class has the right class and properties.
+ */
+ switch (ctx->cur_fc->type) {
+ case CTF_FIELD_CLASS_TYPE_VARIANT:
+ if (target_fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(
+ "Variant field class's tag field class is not an enumeration field class: "
+ "tag-fc-addr=%p, tag-fc-id=%d",
+ target_fc, target_fc->type);
+ ret = -1;
+ goto end;
+ }
+ break;
+ case CTF_FIELD_CLASS_TYPE_SEQUENCE:
+ {
+ if (target_fc->type != CTF_FIELD_CLASS_TYPE_INT &&
+ target_fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(
+ "Sequence field class's length field class is not an unsigned integer field class: "
+ "length-fc-addr=%p, length-fc-id=%d",
+ target_fc, target_fc->type);
+ ret = -1;
+ goto end;
+ }
+
+ ctf_field_class_int *int_fc = ctf_field_class_as_int(target_fc);
+
+ if (int_fc->is_signed) {
+ _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(
+ "Sequence field class's length field class is not an unsigned integer field class: "
+ "length-fc-addr=%p, length-fc-id=%d",
+ target_fc, target_fc->type);
+ ret = -1;
+ goto end;
+ }
+ break;
+ }
+ default:
+ bt_common_abort();
+ }