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>
This commit is contained in:
parent
a086e19d3b
commit
74c4d5ae2a
1 changed files with 1 additions and 1 deletions
|
@ -48,7 +48,7 @@ int fputs(const char *_MLIBC_RESTRICT string, FILE *_MLIBC_RESTRICT stream)
|
|||
int len = strlen(string);
|
||||
int ret;
|
||||
|
||||
ret = fwrite(string, len, 1, stream);
|
||||
ret = fwrite(string, 1, len, stream);
|
||||
|
||||
return len == ret ? 0 : EOF;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue