Merge pull request #1311 from jonathanwright-ARM/jw/MISRA-EOF-usage

stdlib: remove comparison with EOF macro to comply with MISRA
This commit is contained in:
davidcunado-arm 2018-03-22 06:17:37 +00:00 committed by GitHub
commit fbdadd015d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 13 deletions

View File

@ -9,23 +9,17 @@
int puts(const char *s)
{
int count = 0;
while(*s)
{
if (putchar(*s++) != EOF) {
count++;
} else {
count = EOF;
break;
}
while(*s) {
if (putchar(*s++) == EOF)
return EOF;
count++;
}
/* According to the puts(3) manpage, the function should write a
* trailing newline.
*/
if ((count != EOF) && (putchar('\n') != EOF))
count++;
else
count = EOF;
if (putchar('\n') == EOF)
return EOF;
return count;
return count + 1;
}