[PATCH] libgloss: arm: Report an error when a non-empty write makes no progress
Torbjörn SVENSSON
torbjorn.svensson@foss.st.com
Sun Nov 15 20:19:24 GMT 2026
This change fixes the folling fails in r17-6278-g17307249258749:
FAIL: 27_io/basic_filebuf/overflow/char/118099.cc -std=gnu++20 execution test
PASS: 27_io/basic_filebuf/overflow/wchar_t/118099.cc -std=gnu++20 execution test
Ok for master?
--
Return -1 instead of 0 when semihosting fails to write any of the
requested bytes, and retrieve errno from the host. Leave zero-length
writes returning 0 without touching errno.
This fixes a problem exposed by GCC r17-6278-g17307249258749 and
r16-9916-g68b1b9056c70ac (PR118099).
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
---
libgloss/arm/syscalls.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libgloss/arm/syscalls.c b/libgloss/arm/syscalls.c
index 710a741ee..ef58e8164 100644
--- a/libgloss/arm/syscalls.c
+++ b/libgloss/arm/syscalls.c
@@ -544,8 +544,8 @@ _write (int fd, const void * ptr, size_t len)
/* We wrote 0 bytes?
Retrieve errno just in case. */
- if ((len - res) == 0)
- return error (0);
+ if (len != 0 && res == len)
+ return error (-1);
return (len - res);
}
--
2.43.0
More information about the Newlib
mailing list