[lttng-dev] [Babeltrace RFC PATCH 28/28] Open files as binary under Windows

Ikaheimonen, JP jp_ikaheimonen at mentor.com
Thu May 2 08:09:06 EDT 2013


---
 formats/ctf/ctf.c                     | 2 +-
 include/babeltrace/compat/memstream.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c
index 7878555..c6c18a2 100644
--- a/formats/ctf/ctf.c
+++ b/formats/ctf/ctf.c
@@ -1085,7 +1085,7 @@ int ctf_open_trace_metadata_read(struct ctf_trace *td,
 			goto end_free;
 		}
 
-		fp = fdopen(metadata_stream->pos.fd, "r");
+		fp = fdopen(metadata_stream->pos.fd, "rb");
 		if (!fp) {
 			fprintf(stderr, "[error] Unable to open metadata stream.\n");
 			perror("Metadata stream open");
diff --git a/include/babeltrace/compat/memstream.h b/include/babeltrace/compat/memstream.h
index 44bc30c..be6d1a6 100644
--- a/include/babeltrace/compat/memstream.h
+++ b/include/babeltrace/compat/memstream.h
@@ -70,7 +70,7 @@ FILE *babeltrace_fmemopen(void *buf, size_t size, const char *mode)
 	/*
 	 * We need to write to the file.
 	 */
-	fp = fdopen(ret, "w+");
+	fp = fdopen(ret, "w+b");
 	if (!fp) {
 		goto error_unlink;
 	}
@@ -151,7 +151,7 @@ FILE *babeltrace_open_memstream(char **ptr, size_t *sizeloc)
 	if (ret < 0) {
 		return NULL;
 	}
-	fp = fdopen(ret, "w+");
+	fp = fdopen(ret, "w+b");
 	if (!fp) {
 		goto error_unlink;
 	}
-- 
1.8.1.msysgit.1




More information about the lttng-dev mailing list