#include <babeltrace/object-internal.h>
#include <babeltrace/ref.h>
#include <babeltrace/compiler.h>
+#include <babeltrace/compat/fcntl.h>
#define PACKET_LEN_INCREMENT (getpagesize() * 8 * CHAR_BIT)
{
struct bt_ctf_field *field = NULL;
enum ctf_type_id type_id;
+ int ret;
if (!type) {
goto error;
}
type_id = bt_ctf_field_type_get_type_id(type);
- if (type_id <= CTF_TYPE_UNKNOWN || type_id >= NR_CTF_TYPES ||
- bt_ctf_field_type_validate(type)) {
+ if (type_id <= CTF_TYPE_UNKNOWN || type_id >= NR_CTF_TYPES) {
+ goto error;
+ }
+
+ /* Field class MUST be valid */
+ ret = bt_ctf_field_type_validate(type);
+
+ if (ret) {
+ /* Invalid */
goto error;
}
expected_field_type =
bt_ctf_field_type_structure_get_field_type_by_name(field->type,
name);
- if (expected_field_type != value->type) {
+
+ if (bt_ctf_field_type_compare(expected_field_type, value->type)) {
ret = -1;
goto end;
}
cur_tag_container =
bt_ctf_field_enumeration_get_container(variant->tag);
+ assert(cur_tag_container);
cur_tag_enum_integer = container_of(cur_tag_container,
struct bt_ctf_field_integer, parent);
bt_put(cur_tag_container);
}
pos->packet_size += PACKET_LEN_INCREMENT;
- ret = posix_fallocate(pos->fd, pos->mmap_offset,
- pos->packet_size / CHAR_BIT);
+ do {
+ ret = bt_posix_fallocate(pos->fd, pos->mmap_offset,
+ pos->packet_size / CHAR_BIT);
+ } while (ret == EINTR);
if (ret) {
+ errno = EINTR;
+ ret = -1;
goto end;
}