#include <babeltrace/ctf-writer/event-fields-internal.h>
#include <babeltrace/ctf-writer/event-types-internal.h>
#include <babeltrace/compiler.h>
+#include <babeltrace/compat/fcntl.h>
#define PACKET_LEN_INCREMENT (getpagesize() * 8 * CHAR_BIT)
}
type_id = bt_ctf_field_type_get_type_id(type);
- if (type_id <= CTF_TYPE_UNKNOWN ||
- type_id >= NR_CTF_TYPES) {
+ if (type_id <= CTF_TYPE_UNKNOWN || type_id >= NR_CTF_TYPES ||
+ bt_ctf_field_type_validate(type)) {
goto error;
}
tag_enum_integer = container_of(tag_enum, struct bt_ctf_field_integer,
parent);
- if (!bt_ctf_field_validate(variant->tag)) {
+ if (bt_ctf_field_validate(tag_field) < 0) {
goto end;
}
}
size = integer_type->declaration.len;
- min_value = -((int64_t)1 << (size - 1));
- max_value = ((int64_t)1 << (size - 1)) - 1;
+ min_value = -(1ULL << (size - 1));
+ max_value = (1ULL << (size - 1)) - 1;
if (value < min_value || value > max_value) {
ret = -1;
goto end;
static
int bt_ctf_field_generic_validate(struct bt_ctf_field *field)
{
- return !(field && field->payload_set);
+ return (field && field->payload_set) ? 0 : -1;
}
static
while (!ctf_pos_access_ok(pos,
offset_align(pos->offset,
field->type->declaration->alignment))) {
- increase_packet_size(pos);
+ ret = increase_packet_size(pos);
+ if (ret) {
+ goto end;
+ }
}
- ctf_align_pos(pos, field->type->declaration->alignment);
+ if (!ctf_align_pos(pos, field->type->declaration->alignment)) {
+ ret = -1;
+ goto end;
+ }
for (i = 0; i < structure->fields->len; i++) {
struct bt_ctf_field *field = g_ptr_array_index(
break;
}
}
-
+end:
return ret;
}
}
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;
}