X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fctf.c;h=8b9441fdd701ea078bd2839b1009af05e5e1b117;hb=82662ad4362f791f9cd7026652f60708923554f4;hp=0af34aab01412b6c558b0157bf550d30b87b9a59;hpb=f571dfb1ed9909c45274be95489e10f5c1432ff3;p=babeltrace.git diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index 0af34aab..8b9441fd 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -606,9 +606,10 @@ int ctf_open_trace_metadata_stream_read(struct ctf_trace *td, FILE **fp, * \0). This is the allocated size, not the actual string size. */ out = open_memstream(buf, &size); - if (out == NULL) + if (out == NULL) { + perror("Metadata open_memstream"); return -errno; - + } for (;;) { ret = ctf_open_trace_metadata_packet_read(td, in, out); if (ret) { @@ -623,6 +624,10 @@ int ctf_open_trace_metadata_stream_read(struct ctf_trace *td, FILE **fp, fclose(in); /* open for reading */ *fp = fmemopen(*buf, strlen(*buf), "rb"); + if (!*fp) { + perror("Metadata fmemopen"); + return -errno; + } return 0; } @@ -660,6 +665,7 @@ int ctf_open_trace_metadata_read(struct ctf_trace *td, fp = fdopen(metadata_stream->pos.fd, "r"); if (!fp) { fprintf(stdout, "[error] Unable to open metadata stream.\n"); + perror("Metadata stream open"); ret = -errno; goto end_stream; } @@ -1097,8 +1103,10 @@ int ctf_open_file_stream_read(struct ctf_trace *td, const char *path, int flags, struct ctf_file_stream *file_stream; ret = openat(td->dirfd, path, flags); - if (ret < 0) + if (ret < 0) { + perror("File stream openat()"); goto error; + } file_stream = g_new0(struct ctf_file_stream, 1); if (move_pos_slow) { @@ -1155,9 +1163,12 @@ int ctf_open_trace_read(struct ctf_trace *td, const char *path, int flags, td->dirfd = open(path, 0); if (td->dirfd < 0) { fprintf(stdout, "[error] Unable to open trace directory file descriptor.\n"); - ret = -ENOENT; + perror("Trace directory open"); + ret = -errno; goto error_dirfd; } + strncpy(td->path, path, PATH_MAX); + td->path[PATH_MAX - 1] = '\0'; /* * Keep the metadata file separate.