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(
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: "
ctf_field_class_struct_borrow_member_int_field_class_by_name(
struct ctf_field_class_struct *struct_fc, const char *name)
{
- struct ctf_field_class_int *int_fc = NULL;
+ ctf_field_class *member_fc =
+ ctf_field_class_struct_borrow_member_field_class_by_name(struct_fc, name);
- int_fc = ctf_field_class_as_int(
- ctf_field_class_struct_borrow_member_field_class_by_name(struct_fc, name));
- if (!int_fc) {
- goto end;
+ if (!member_fc) {
+ return nullptr;
}
- if (int_fc->base.base.type != CTF_FIELD_CLASS_TYPE_INT &&
- int_fc->base.base.type != CTF_FIELD_CLASS_TYPE_ENUM) {
- int_fc = NULL;
- goto end;
+ if (member_fc->type != CTF_FIELD_CLASS_TYPE_INT &&
+ member_fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
+ return nullptr;
}
-end:
- return int_fc;
+ return ctf_field_class_as_int(member_fc);
}
static inline void _ctf_named_field_class_unescape_orig_name(struct ctf_named_field_class *named_fc)
struct ctf_field_class *fc)
{
struct ctf_clock_class *clock_class_to_map_to = NULL;
- struct ctf_field_class_int *int_fc = ctf_field_class_as_int(fc);
- int ret = 0;
uint64_t clock_class_count;
if (!fc) {
- goto end;
+ return 0;
}
if (fc->type != CTF_FIELD_CLASS_TYPE_INT && fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
- goto end;
+ return 0;
}
+ ctf_field_class_int *int_fc = ctf_field_class_as_int(fc);
+
if (int_fc->mapped_clock_class) {
/* Already mapped */
- goto end;
+ return 0;
}
clock_class_count = ctx->ctf_tc->clock_classes->len;
BT_ASSERT(clock_class_to_map_to);
clock_class_to_map_to->frequency = UINT64_C(1000000000);
g_string_assign(clock_class_to_map_to->name, "default");
- BT_ASSERT(ret == 0);
g_ptr_array_add(ctx->ctf_tc->clock_classes, clock_class_to_map_to);
break;
case 1:
_BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(
"Timestamp field found with no mapped clock class, "
"but there's more than one clock class in the trace at this point.");
- ret = -1;
- goto end;
+ return -1;
}
BT_ASSERT(clock_class_to_map_to);
int_fc->mapped_clock_class = clock_class_to_map_to;
-end:
- return ret;
+ return 0;
}
static int auto_map_fields_to_trace_clock_class(struct ctf_visitor_generate_ir *ctx,
enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
bt_field *field = NULL;
- ctf_field_class_int *int_fc = ctf_field_class_as_int(fc);
BT_COMP_LOGT("Unsigned integer function called from BFCR: "
"msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, "
"fc-type=%d, fc-in-ir=%d, value=%" PRIu64,
msg_it, msg_it->bfcr, fc, fc->type, fc->in_ir, value);
+ ctf_field_class_int *int_fc = ctf_field_class_as_int(fc);
+
if (G_LIKELY(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE)) {
goto update_def_clock;
}
bt_self_component *self_comp = msg_it->self_comp;
enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
bt_field *string_field = NULL;
- ctf_field_class_int *int_fc = ctf_field_class_as_int(fc);
char str[2] = {'\0', '\0'};
BT_COMP_LOGT("Unsigned integer character function called from BFCR: "
"msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, "
"fc-type=%d, fc-in-ir=%d, value=%" PRIu64,
msg_it, msg_it->bfcr, fc, fc->type, fc->in_ir, value);
+
+ ctf_field_class_int *int_fc = ctf_field_class_as_int(fc);
BT_ASSERT_DBG(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE);
BT_ASSERT_DBG(!int_fc->mapped_clock_class);
BT_ASSERT_DBG(int_fc->storing_index < 0);
enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
bt_field *field = NULL;
ctf_msg_iter *msg_it = (ctf_msg_iter *) data;
- ctf_field_class_int *int_fc = ctf_field_class_as_int(fc);
BT_COMP_LOGT("Signed integer function called from BFCR: "
"msg-it-addr=%p, bfcr-addr=%p, fc-addr=%p, "
"fc-type=%d, fc-in-ir=%d, value=%" PRId64,
msg_it, msg_it->bfcr, fc, fc->type, fc->in_ir, value);
+
+ ctf_field_class_int *int_fc = ctf_field_class_as_int(fc);
BT_ASSERT_DBG(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE);
if (G_UNLIKELY(int_fc->storing_index >= 0)) {
--- /dev/null
+/* CTF 1.8 */
+typealias integer { size = 8; align = 8; signed = false; } := uint8_t;
+
+trace {
+ major = 1;
+ minor = 8;
+ byte_order = le;
+};
+
+stream {
+ event.header := struct {
+ uint8_t id;
+ };
+};
+
+event {
+ name = ze_event;
+ id = 1;
+ fields := struct {
+ struct {
+ uint8_t hello;
+ } len;
+ uint8_t x[len];
+ };
+};
--- /dev/null
+/* CTF 1.8 */
+typealias integer { size = 8; align = 8; signed = false; } := uint8_t;
+
+trace {
+ major = 1;
+ minor = 8;
+ byte_order = le;
+};
+
+stream {
+ event.header := struct {
+ uint8_t id;
+ };
+};
+
+event {
+ name = ze_event;
+ id = 1;
+ fields := struct {
+ struct {
+ uint8_t hello;
+ } selector;
+ variant<selector> {
+ uint8_t a;
+ uint8_t b;
+ } v;
+ };
+};
}
-plan_tests 12
+plan_tests 20
test_fail \
"invalid-packet-size/trace" \
"/dev/null" \
"^ At line 3 in metadata stream: syntax error, unexpected CTF_RSBRAC: token=\"]\""
+test_fail \
+ "invalid-sequence-length-field-class" \
+ "/dev/null" \
+ "Sequence field class's length field class is not an unsigned integer field class: "
+
+test_fail \
+ "invalid-variant-selector-field-class" \
+ "/dev/null" \
+ "Variant field class's tag field class is not an enumeration field class: "
+
rm -f "${stdout_file}" "${stderr_file}"