zephyr/lib
Eugeniy Paltsev 74c4d5ae2a libc: minimal: stdout: fix fputs return value
The 'fputs' has flaw in the implementation. It almost always
returns 'EOF' even if completed successfully.
This happens because we compare 'fwrite' return value which is
"number of members successfully written" (which is 1 in current
implementation) to the total string size:

----------------------------->8-----------------------
int fputs(const char *_MLIBC_RESTRICT string,
          FILE *_MLIBC_RESTRICT stream)
{
	int len = strlen(string);
	int ret;

	ret = fwrite(string, len, 1, stream);

	return len == ret ? 0 : EOF;
}
----------------------------->8-----------------------

In result 'fputs' return 'EOF' in case of string length bigger
than 1.

There are several fixes possible, and one of the fixes is to
swap number of items (1) with size (string length) when we
are calling 'fwrite'. The only difference will be that
'fwrite' will return actual numbers of bytes written which
can be compared with the string length.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2021-01-19 23:03:12 -05:00
..
cmsis_rtos_v1 cmsis: align buffer containing struct k_timer 2020-11-13 14:53:55 -08:00
cmsis_rtos_v2 lib: cmsis_rtos_v2: Handle possible zero length array 2020-09-18 10:13:58 -05:00
fnmatch ext: lib: Move fnmatch to lib/ 2020-03-20 22:56:19 -04:00
gui kernel: subsys: lib: drivers: Use k_heap instead of z_mem_pool wrappers 2020-12-07 21:50:14 -05:00
libc libc: minimal: stdout: fix fputs return value 2021-01-19 23:03:12 -05:00
open-amp lib: open-amp: add helper to add resource table in project 2020-04-01 09:21:15 -05:00
os tests: ringbuffer: code coverage improvements 2021-01-18 23:12:47 -05:00
posix lib/posix: SPARC newlib has unsigned short mode_t 2020-11-13 14:53:55 -08:00
CMakeLists.txt updatehub: Move from lib to subsys:mgmt folder 2020-08-03 16:33:06 +02:00
Kconfig updatehub: Move from lib to subsys:mgmt folder 2020-08-03 16:33:06 +02:00