ir: rename ctf_string_encoding -> bt_ctf_string_encoding
[babeltrace.git] / formats / ctf / ir / event-fields.c
index 1092dc314d9d8ac08ab39476f39a5afcd1f16daa..4383e2a33783ee221af1115a493bf1845ff46c6a 100644 (file)
@@ -32,6 +32,7 @@
 #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)
 
@@ -233,14 +234,22 @@ struct bt_ctf_field *bt_ctf_field_create(struct bt_ctf_field_type *type)
 {
        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;
        }
 
@@ -526,7 +535,8 @@ int bt_ctf_field_structure_set_field(struct bt_ctf_field *field,
        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;
        }
@@ -667,6 +677,7 @@ struct bt_ctf_field *bt_ctf_field_variant_get_field(struct bt_ctf_field *field,
 
                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);
@@ -2170,9 +2181,13 @@ int increase_packet_size(struct ctf_stream_pos *pos)
        }
 
        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;
        }
 
This page took 0.032778 seconds and 4 git commands to generate.