[PATCH 1/4] scripts: common: fix read_file_2 for windows
Marco Felsch
m.felsch at pengutronix.de
Tue Oct 17 14:36:05 PDT 2023
From: Marco Felsch <marco.felsch at gmail.com>
We need to specify the O_BINARY flag for Windows else the followed
read() may detected a EOF condition.
Signed-off-by: Marco Felsch <m.felsch at pengutronix.de>
---
scripts/common.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/common.c b/scripts/common.c
index 88173bc977..0599cd41ff 100644
--- a/scripts/common.c
+++ b/scripts/common.c
@@ -11,6 +11,7 @@
#include <stdarg.h>
#include "common.h"
+#include "compiler.h"
int read_file_2(const char *filename, size_t *size, void **outbuf, size_t max_size)
{
@@ -22,7 +23,7 @@ int read_file_2(const char *filename, size_t *size, void **outbuf, size_t max_si
*size = 0;
*outbuf = NULL;
- fd = open(filename, O_RDONLY);
+ fd = open(filename, O_RDONLY | O_BINARY);
if (fd < 0) {
fprintf(stderr, "Cannot open %s: %s\n", filename, strerror(errno));
return -errno;
--
2.41.0
More information about the barebox
mailing list