X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fctf.c;h=a32e0cc03d819f5886ef49ffe171ac95f15a5587;hb=f6afb94e88f4fb2a47384559fe14ad82a3ec7f20;hp=58b5488920d006e71aafe96b764e5f49ec7c5b6d;hpb=fcf104173870de4678c8f69e33039d39193c939a;p=babeltrace.git diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index 58b54889..a32e0cc0 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -908,7 +908,7 @@ void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence) pos->packet_size = WRITE_PACKET_LEN; off = 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: @@ -1855,10 +1855,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 +1964,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 +2003,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 +2062,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);