int bt_ctf_field_sequence_validate(struct bt_ctf_field *);
static
-int bt_ctf_field_generic_reset(struct bt_ctf_field *);
+int bt_ctf_field_generic_reset_value(struct bt_ctf_field *);
static
-int bt_ctf_field_structure_reset(struct bt_ctf_field *);
+int bt_ctf_field_structure_reset_value(struct bt_ctf_field *);
static
-int bt_ctf_field_variant_reset(struct bt_ctf_field *);
+int bt_ctf_field_variant_reset_value(struct bt_ctf_field *);
static
-int bt_ctf_field_enumeration_reset(struct bt_ctf_field *);
+int bt_ctf_field_enumeration_reset_value(struct bt_ctf_field *);
static
-int bt_ctf_field_array_reset(struct bt_ctf_field *);
+int bt_ctf_field_array_reset_value(struct bt_ctf_field *);
static
-int bt_ctf_field_sequence_reset(struct bt_ctf_field *);
+int bt_ctf_field_sequence_reset_value(struct bt_ctf_field *);
static
-int bt_ctf_field_string_reset(struct bt_ctf_field *);
+int bt_ctf_field_string_reset_value(struct bt_ctf_field *);
static
int bt_ctf_field_integer_serialize(struct bt_ctf_field *,
void bt_ctf_field_sequence_freeze(struct bt_ctf_field *);
static
-bt_bool bt_ctf_field_generic_is_set(struct bt_ctf_field *);
+bt_bool bt_ctf_field_generic_value_is_set(struct bt_ctf_field *);
static
-bt_bool bt_ctf_field_structure_is_set(struct bt_ctf_field *);
+bt_bool bt_ctf_field_structure_value_is_set(struct bt_ctf_field *);
static
-bt_bool bt_ctf_field_variant_is_set(struct bt_ctf_field *);
+bt_bool bt_ctf_field_variant_value_is_set(struct bt_ctf_field *);
static
-bt_bool bt_ctf_field_enumeration_is_set(struct bt_ctf_field *);
+bt_bool bt_ctf_field_enumeration_value_is_set(struct bt_ctf_field *);
static
-bt_bool bt_ctf_field_array_is_set(struct bt_ctf_field *);
+bt_bool bt_ctf_field_array_value_is_set(struct bt_ctf_field *);
static
-bt_bool bt_ctf_field_sequence_is_set(struct bt_ctf_field *);
+bt_bool bt_ctf_field_sequence_value_is_set(struct bt_ctf_field *);
static
int increase_packet_size(struct bt_ctf_stream_pos *pos);
};
static
-int (* const field_reset_funcs[])(struct bt_ctf_field *) = {
- [BT_CTF_FIELD_TYPE_ID_INTEGER] = bt_ctf_field_generic_reset,
- [BT_CTF_FIELD_TYPE_ID_ENUM] = bt_ctf_field_enumeration_reset,
- [BT_CTF_FIELD_TYPE_ID_FLOAT] = bt_ctf_field_generic_reset,
- [BT_CTF_FIELD_TYPE_ID_STRUCT] = bt_ctf_field_structure_reset,
- [BT_CTF_FIELD_TYPE_ID_VARIANT] = bt_ctf_field_variant_reset,
- [BT_CTF_FIELD_TYPE_ID_ARRAY] = bt_ctf_field_array_reset,
- [BT_CTF_FIELD_TYPE_ID_SEQUENCE] = bt_ctf_field_sequence_reset,
- [BT_CTF_FIELD_TYPE_ID_STRING] = bt_ctf_field_string_reset,
+int (* const field_reset_value_funcs[])(struct bt_ctf_field *) = {
+ [BT_CTF_FIELD_TYPE_ID_INTEGER] = bt_ctf_field_generic_reset_value,
+ [BT_CTF_FIELD_TYPE_ID_ENUM] = bt_ctf_field_enumeration_reset_value,
+ [BT_CTF_FIELD_TYPE_ID_FLOAT] = bt_ctf_field_generic_reset_value,
+ [BT_CTF_FIELD_TYPE_ID_STRUCT] = bt_ctf_field_structure_reset_value,
+ [BT_CTF_FIELD_TYPE_ID_VARIANT] = bt_ctf_field_variant_reset_value,
+ [BT_CTF_FIELD_TYPE_ID_ARRAY] = bt_ctf_field_array_reset_value,
+ [BT_CTF_FIELD_TYPE_ID_SEQUENCE] = bt_ctf_field_sequence_reset_value,
+ [BT_CTF_FIELD_TYPE_ID_STRING] = bt_ctf_field_string_reset_value,
};
static
};
static
-bt_bool (* const field_is_set_funcs[])(struct bt_ctf_field *) = {
- [BT_CTF_FIELD_TYPE_ID_INTEGER] = bt_ctf_field_generic_is_set,
- [BT_CTF_FIELD_TYPE_ID_ENUM] = bt_ctf_field_enumeration_is_set,
- [BT_CTF_FIELD_TYPE_ID_FLOAT] = bt_ctf_field_generic_is_set,
- [BT_CTF_FIELD_TYPE_ID_STRUCT] = bt_ctf_field_structure_is_set,
- [BT_CTF_FIELD_TYPE_ID_VARIANT] = bt_ctf_field_variant_is_set,
- [BT_CTF_FIELD_TYPE_ID_ARRAY] = bt_ctf_field_array_is_set,
- [BT_CTF_FIELD_TYPE_ID_SEQUENCE] = bt_ctf_field_sequence_is_set,
- [BT_CTF_FIELD_TYPE_ID_STRING] = bt_ctf_field_generic_is_set,
+bt_bool (* const field_value_is_set_funcs[])(struct bt_ctf_field *) = {
+ [BT_CTF_FIELD_TYPE_ID_INTEGER] = bt_ctf_field_generic_value_is_set,
+ [BT_CTF_FIELD_TYPE_ID_ENUM] = bt_ctf_field_enumeration_value_is_set,
+ [BT_CTF_FIELD_TYPE_ID_FLOAT] = bt_ctf_field_generic_value_is_set,
+ [BT_CTF_FIELD_TYPE_ID_STRUCT] = bt_ctf_field_structure_value_is_set,
+ [BT_CTF_FIELD_TYPE_ID_VARIANT] = bt_ctf_field_variant_value_is_set,
+ [BT_CTF_FIELD_TYPE_ID_ARRAY] = bt_ctf_field_array_value_is_set,
+ [BT_CTF_FIELD_TYPE_ID_SEQUENCE] = bt_ctf_field_sequence_value_is_set,
+ [BT_CTF_FIELD_TYPE_ID_STRING] = bt_ctf_field_generic_value_is_set,
};
struct bt_ctf_field *bt_ctf_field_create(struct bt_ctf_field_type *type)
return ret;
}
-BT_HIDDEN
-int bt_ctf_field_reset(struct bt_ctf_field *field)
+int bt_ctf_field_reset_value(struct bt_ctf_field *field)
{
int ret = 0;
enum bt_ctf_field_type_id type_id;
goto end;
}
+ if (field->frozen) {
+ BT_LOGW("Invalid parameter: field is frozen: addr=%p",
+ field);
+ ret = -1;
+ goto end;
+ }
+
type_id = bt_ctf_field_type_get_type_id(field->type);
if (type_id <= BT_CTF_FIELD_TYPE_ID_UNKNOWN || type_id >= BT_CTF_NR_TYPE_IDS) {
BT_LOGW("Invalid parameter: unknown field type ID: "
goto end;
}
- ret = field_reset_funcs[type_id](field);
+ ret = field_reset_value_funcs[type_id](field);
end:
return ret;
}
return ret;
}
-
-BT_HIDDEN
-bt_bool bt_ctf_field_is_set(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_value_is_set(struct bt_ctf_field *field)
{
- bt_bool is_set = BT_FALSE;
+ bt_bool value_is_set = BT_FALSE;
enum bt_ctf_field_type_id type_id;
if (!field) {
goto end;
}
- is_set = field_is_set_funcs[type_id](field);
+ value_is_set = field_value_is_set_funcs[type_id](field);
end:
- return is_set;
+ return value_is_set;
}
struct bt_ctf_field *bt_ctf_field_copy(struct bt_ctf_field *field)
}
static
-int bt_ctf_field_generic_reset(struct bt_ctf_field *field)
+int bt_ctf_field_generic_reset_value(struct bt_ctf_field *field)
{
int ret = 0;
}
static
-int bt_ctf_field_enumeration_reset(struct bt_ctf_field *field)
+int bt_ctf_field_enumeration_reset_value(struct bt_ctf_field *field)
{
int ret = 0;
struct bt_ctf_field_enumeration *enumeration;
goto end;
}
- ret = bt_ctf_field_reset(enumeration->payload);
+ ret = bt_ctf_field_reset_value(enumeration->payload);
end:
return ret;
}
static
-int bt_ctf_field_structure_reset(struct bt_ctf_field *field)
+int bt_ctf_field_structure_reset_value(struct bt_ctf_field *field)
{
int64_t i;
int ret = 0;
continue;
}
- ret = bt_ctf_field_reset(member);
+ ret = bt_ctf_field_reset_value(member);
if (ret) {
BT_LOGE("Failed to reset structure field's field: "
"struct-field-addr=%p, field-addr=%p, "
}
static
-int bt_ctf_field_variant_reset(struct bt_ctf_field *field)
+int bt_ctf_field_variant_reset_value(struct bt_ctf_field *field)
{
int ret = 0;
struct bt_ctf_field_variant *variant;
}
variant = container_of(field, struct bt_ctf_field_variant, parent);
- if (variant->payload) {
- ret = bt_ctf_field_reset(variant->payload);
- if (ret) {
- BT_LOGW("Failed to reset variant field's payload field: "
- "variant-field-addr=%p, payload-field-addr=%p",
- field, variant->payload);
- }
- }
+ BT_PUT(variant->tag);
+ BT_PUT(variant->payload);
end:
return ret;
}
static
-int bt_ctf_field_array_reset(struct bt_ctf_field *field)
+int bt_ctf_field_array_reset_value(struct bt_ctf_field *field)
{
size_t i;
int ret = 0;
continue;
}
- ret = bt_ctf_field_reset(member);
+ ret = bt_ctf_field_reset_value(member);
if (ret) {
BT_LOGE("Failed to reset array field's field: "
"array-field-addr=%p, field-addr=%p, "
}
static
-int bt_ctf_field_sequence_reset(struct bt_ctf_field *field)
+int bt_ctf_field_sequence_reset_value(struct bt_ctf_field *field)
{
- size_t i;
int ret = 0;
struct bt_ctf_field_sequence *sequence;
}
sequence = container_of(field, struct bt_ctf_field_sequence, parent);
- for (i = 0; i < sequence->elements->len; i++) {
- struct bt_ctf_field *member = sequence->elements->pdata[i];
-
- if (!member) {
- /*
- * Sequence elements are lazily initialized; skip if
- * this member has not been allocated yet.
- */
- continue;
- }
-
- ret = bt_ctf_field_reset(member);
- if (ret) {
- BT_LOGE("Failed to reset sequence field's field: "
- "sequence-field-addr=%p, field-addr=%p, "
- "index=%zu", field, member, i);
- goto end;
- }
+ if (sequence->elements) {
+ g_ptr_array_free(sequence->elements, TRUE);
+ sequence->elements = NULL;
}
+ BT_PUT(sequence->length);
end:
return ret;
}
static
-int bt_ctf_field_string_reset(struct bt_ctf_field *field)
+int bt_ctf_field_string_reset_value(struct bt_ctf_field *field)
{
int ret = 0;
struct bt_ctf_field_string *string;
goto end;
}
- ret = bt_ctf_field_generic_reset(field);
+ ret = bt_ctf_field_generic_reset_value(field);
if (ret) {
goto end;
}
"native-bo=%s", field, pos->offset,
bt_ctf_byte_order_string(native_byte_order));
- if (!bt_ctf_field_generic_is_set(field)) {
+ if (!bt_ctf_field_generic_value_is_set(field)) {
BT_LOGW_STR("Field's payload is not set.");
ret = -1;
goto end;
"native-bo=%s", field, pos->offset,
bt_ctf_byte_order_string(native_byte_order));
- if (!bt_ctf_field_generic_is_set(field)) {
+ if (!bt_ctf_field_generic_value_is_set(field)) {
BT_LOGW_STR("Field's payload is not set.");
ret = -1;
goto end;
}
static
-bt_bool bt_ctf_field_generic_is_set(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_generic_value_is_set(struct bt_ctf_field *field)
{
return field && field->payload_set;
}
static
-bt_bool bt_ctf_field_enumeration_is_set(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_enumeration_value_is_set(struct bt_ctf_field *field)
{
- bt_bool is_set = BT_FALSE;
+ bt_bool value_is_set = BT_FALSE;
struct bt_ctf_field_enumeration *enumeration;
if (!field) {
goto end;
}
- is_set = bt_ctf_field_is_set(enumeration->payload);
+ value_is_set = bt_ctf_field_value_is_set(enumeration->payload);
end:
- return is_set;
+ return value_is_set;
}
static
-bt_bool bt_ctf_field_structure_is_set(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_structure_value_is_set(struct bt_ctf_field *field)
{
- bt_bool is_set = BT_FALSE;
+ bt_bool value_is_set = BT_FALSE;
size_t i;
struct bt_ctf_field_structure *structure;
structure = container_of(field, struct bt_ctf_field_structure, parent);
for (i = 0; i < structure->fields->len; i++) {
- is_set = bt_ctf_field_is_set(structure->fields->pdata[i]);
- if (!is_set) {
+ value_is_set = bt_ctf_field_value_is_set(structure->fields->pdata[i]);
+ if (!value_is_set) {
goto end;
}
}
end:
- return is_set;
+ return value_is_set;
}
static
-bt_bool bt_ctf_field_variant_is_set(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_variant_value_is_set(struct bt_ctf_field *field)
{
- bt_bool is_set = BT_FALSE;
+ bt_bool value_is_set = BT_FALSE;
struct bt_ctf_field_variant *variant;
if (!field) {
}
variant = container_of(field, struct bt_ctf_field_variant, parent);
- is_set = bt_ctf_field_is_set(variant->payload);
+ value_is_set = bt_ctf_field_value_is_set(variant->payload);
end:
- return is_set;
+ return value_is_set;
}
static
-bt_bool bt_ctf_field_array_is_set(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_array_value_is_set(struct bt_ctf_field *field)
{
size_t i;
- bt_bool is_set = BT_FALSE;
+ bt_bool value_is_set = BT_FALSE;
struct bt_ctf_field_array *array;
if (!field) {
array = container_of(field, struct bt_ctf_field_array, parent);
for (i = 0; i < array->elements->len; i++) {
- is_set = bt_ctf_field_is_set(array->elements->pdata[i]);
- if (!is_set) {
+ value_is_set = bt_ctf_field_value_is_set(array->elements->pdata[i]);
+ if (!value_is_set) {
goto end;
}
}
end:
- return is_set;
+ return value_is_set;
}
static
-bt_bool bt_ctf_field_sequence_is_set(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_sequence_value_is_set(struct bt_ctf_field *field)
{
size_t i;
- bt_bool is_set = BT_FALSE;
+ bt_bool value_is_set = BT_FALSE;
struct bt_ctf_field_sequence *sequence;
if (!field) {
}
sequence = container_of(field, struct bt_ctf_field_sequence, parent);
+ if (!sequence->elements) {
+ goto end;
+ }
+
for (i = 0; i < sequence->elements->len; i++) {
- is_set = bt_ctf_field_validate(sequence->elements->pdata[i]);
- if (!is_set) {
+ value_is_set = bt_ctf_field_value_is_set(sequence->elements->pdata[i]);
+ if (!value_is_set) {
goto end;
}
}
end:
- return is_set;
+ return value_is_set;
}