cosmopolitan/test/libc
Gabriel Ravier 9c6d78c26d
Fix vfprintf and derived functions not handling write errors (#798)
The C standard states:
> The fprintf function returns the number of characters transmitted,
> or a negative value if an output or encoding error occurred or if
> the implementation does not support a specified width length
> modifier.
- C Standard, 7.23.6.1.15. The fprintf function

However, cosmopolitan fails to return a negative value in the case of
an output error, meaning that a program such as:

 #include <stdio.h>

int main()
{
    FILE *fp = fopen("/dev/full", "w");

    setbuf(fp, NULL);
    printf("fprintf: %d\n", fprintf(fp, "test\n"));
    printf("fflush: %d\n", fflush(fp));
}

will, under cosmopolitan, print that no error occured in either of the
calls to fprintf and fflush.

This patch fixes this, along with the associated GitHub issue,
https://github.com/jart/cosmopolitan/issues/784
2023-03-31 09:57:29 -04:00
..
bits Fold LIBC_BITS into LIBC_INTRIN 2022-08-11 12:13:18 -07:00
calls Add memfd fexecve zipos support (#752) 2023-03-29 18:16:46 -07:00
dns Rename rand64() to _rand64() 2022-10-10 04:12:06 -07:00
fmt Fix vfprintf and derived functions not handling write errors (#798) 2023-03-31 09:57:29 -04:00
intrin Make intrin_test go faster 2023-03-05 22:57:07 -08:00
log Add WSL to test fleet 2022-11-02 06:49:42 -07:00
mem Improve cancellations, randomness, and time 2022-11-05 23:45:32 -07:00
nexgen32e Rename rand64() to _rand64() 2022-10-10 04:12:06 -07:00
release Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
runtime Remove problematic test 2023-02-05 16:50:04 -08:00
sock Update tests and CPU detection for Blink 2023-01-18 00:56:09 -08:00
stdio GetZipCdir: prevent integer underflow. posix_spawn_test.c: stop attempting to load zipos from /usr/bin/ape. (#758) 2023-03-05 14:29:38 -08:00
str Fix larger than WCHAR_MAX differences in wcs{,n}cmp (#795) 2023-03-29 20:28:18 -04:00
thread Make POSIX semaphores always process shared 2023-02-23 08:07:54 -08:00
time Make fixes and improvements 2022-10-19 07:19:19 -07:00
tinymath Pay off more technical debt 2022-09-12 23:36:56 -07:00
x Greatly expand system() shell code features 2022-10-11 21:30:31 -07:00
xed Pay off more technical debt 2022-09-12 23:36:56 -07:00
zipos Add fexecve() and map O_EXEC to O_PATH on Linux 2022-10-02 09:15:46 -07:00
test.mk Don't relocate file descriptor memory 2022-09-09 16:54:28 -07:00