S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
g_free(file_path);
if (fd < 0) {
- BT_LOGW("Failed to open stream file for writing: %s: "
- "filename=\"%s\", "
- "ret=%d, errno=%d", strerror(errno),
- filename->str, fd, errno);
+ BT_LOGW_ERRNO("Failed to open stream file for writing",
+ ": file_path=\"%s\", filename=\"%s\", ret=%d",
+ file_path, filename->str, fd);
goto end;
}
int ret = 0;
struct bt_ctf_field *id_field = NULL, *timestamp_field = NULL;
struct bt_ctf_clock_class *mapped_clock_class = NULL;
- uint64_t event_class_id;
+ int64_t event_class_id;
assert(event);
stream, bt_ctf_stream_get_name(stream), event);
id_field = bt_ctf_field_structure_get_field(event->event_header, "id");
- event_class_id = (uint64_t) bt_ctf_event_class_get_id(event->event_class);
- assert(event_class_id >= 0);
+ event_class_id = bt_ctf_event_class_get_id(event->event_class);
+ if (event_class_id < 0) {
+ BT_LOGE("Event class ID cannot be found");
+ ret = -1;
+ goto end;
+ }
if (id_field && bt_ctf_field_type_is_integer(id_field->type)) {
ret = set_integer_field_value(id_field, event_class_id);
if (ret) {
if (!stream) {
BT_LOGW_STR("Invalid parameter: stream is NULL.");
ret = -1;
- goto end;
+ goto end_no_stream;
}
if (stream->pos.fd < 0) {
stream->flushed_packet_count++;
stream->size += stream->pos.packet_size / CHAR_BIT;
- do {
- ret = ftruncate(stream->pos.fd, stream->size);
- } while (ret == -1 && errno == EINTR);
- if (ret == -1) {
- BT_LOGE_ERRNO("Cannot truncate stream file to new size",
- ": size=%" PRIu64 ", stream-addr=%p, "
- "stream-name=\"%s\"",
- stream->size, stream,
- bt_ctf_stream_get_name(stream));
- }
-
end:
/* Reset automatically-set fields. */
if (stream->packet_context) {
"packet-size=%" PRIu64,
stream->pos.offset, stream->pos.packet_size);
}
+
+end_no_stream:
return ret;
}
ret = ftruncate(stream->pos.fd, stream->size);
} while (ret == -1 && errno == EINTR);
if (ret) {
- BT_LOGE("Failed to truncate stream file: %s: "
- "ret=%d, errno=%d, size=%" PRIu64,
- strerror(errno), ret, errno,
- (uint64_t) stream->size);
+ BT_LOGE_ERRNO("Failed to truncate stream file",
+ ": ret=%d, size=%" PRIu64,
+ ret, (uint64_t) stream->size);
}
if (close(stream->pos.fd)) {
- BT_LOGE("Failed to close stream file: %s: "
- "ret=%d, errno=%d", strerror(errno),
- ret, errno);
+ BT_LOGE_ERRNO("Failed to close stream file",
+ ": ret=%d", ret);
}
}