X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fctf.c;h=af1809efc8a0390986027bded924e6d2b3bb932e;hp=58b5488920d006e71aafe96b764e5f49ec7c5b6d;hb=edcad9c1c88e6e698040855d7518d0c27dfc4489;hpb=fcf104173870de4678c8f69e33039d39193c939a diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index 58b54889..af1809ef 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -53,6 +53,7 @@ #include "metadata/ctf-ast.h" #include "events-private.h" #include +#include #define LOG2_CHAR_BIT 3 @@ -906,9 +907,9 @@ void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence) } pos->content_size = -1U; /* Unknown at this point */ pos->packet_size = WRITE_PACKET_LEN; - off = posix_fallocate(pos->fd, pos->mmap_offset, + off = bt_posix_fallocate(pos->fd, pos->mmap_offset, pos->packet_size / CHAR_BIT); - assert(off >= 0); + assert(off == 0); pos->offset = 0; } else { read_next_packet: @@ -1109,7 +1110,7 @@ int ctf_trace_metadata_packet_read(struct ctf_trace *td, FILE *in, memcpy(td->uuid, header.uuid, sizeof(header.uuid)); CTF_TRACE_SET_FIELD(td, uuid); } else { - if (babeltrace_uuid_compare(header.uuid, td->uuid)) + if (bt_uuid_compare(header.uuid, td->uuid)) return -EINVAL; } @@ -1595,7 +1596,7 @@ begin: elem = bt_array_index(defarray, i); uuidval[i] = bt_get_unsigned_int(elem); } - ret = babeltrace_uuid_compare(td->uuid, uuidval); + ret = bt_uuid_compare(td->uuid, uuidval); if (ret) { fprintf(stderr, "[error] Unique Universal Identifiers do not match.\n"); return -EINVAL; @@ -1855,10 +1856,10 @@ int import_stream_packet_index(struct ctf_trace *td, goto error; } if (be32toh(index_hdr.index_major) != CTF_INDEX_MAJOR) { - fprintf(stderr, "[error] Incompatible index file %" PRIu64 - ".%" PRIu64 ", supported %d.%d\n", - be64toh(index_hdr.index_major), - be64toh(index_hdr.index_minor), CTF_INDEX_MAJOR, + fprintf(stderr, "[error] Incompatible index file %" PRIu32 + ".%" PRIu32 ", supported %d.%d\n", + be32toh(index_hdr.index_major), + be32toh(index_hdr.index_minor), CTF_INDEX_MAJOR, CTF_INDEX_MINOR); ret = -1; goto error; @@ -1964,6 +1965,11 @@ int ctf_open_file_stream_read(struct ctf_trace *td, const char *path, int flags, ret = 0; goto fd_is_dir_ok; } + if (!statbuf.st_size) { + /** Skip empty files. */ + ret = 0; + goto fd_is_empty_file; + } file_stream = g_new0(struct ctf_file_stream, 1); file_stream->pos.last_offset = LAST_OFFSET_POISON; @@ -1998,6 +2004,7 @@ int ctf_open_file_stream_read(struct ctf_trace *td, const char *path, int flags, index_name = malloc((strlen(path) + sizeof(INDEX_PATH)) * sizeof(char)); if (!index_name) { fprintf(stderr, "[error] Cannot allocate index filename\n"); + ret = -ENOMEM; goto error_def; } snprintf(index_name, strlen(path) + sizeof(INDEX_PATH), @@ -2056,6 +2063,7 @@ error_def: fprintf(stderr, "Error on ctf_fini_pos\n"); } g_free(file_stream); +fd_is_empty_file: fd_is_dir_ok: fstat_error: closeret = close(fd);