Commit 5ea28277 authored by Jonathan Wright's avatar Jonathan Wright
Browse files

stdlib: remove comparison with EOF macro to comply with MISRA



Ensures compliance with MISRA C-2012 Rule 22.7

Change-Id: Ifbe0926a24ba0dca18174e1aa87313a63bba50fb
Signed-off-by: default avatarJonathan Wright <jonathan.wright@arm.com>
parent 6dd74c5b
...@@ -9,23 +9,17 @@ ...@@ -9,23 +9,17 @@
int puts(const char *s) int puts(const char *s)
{ {
int count = 0; int count = 0;
while(*s) while(*s) {
{ if (putchar(*s++) == EOF)
if (putchar(*s++) != EOF) { return EOF;
count++; count++;
} else {
count = EOF;
break;
}
} }
/* According to the puts(3) manpage, the function should write a /* According to the puts(3) manpage, the function should write a
* trailing newline. * trailing newline.
*/ */
if ((count != EOF) && (putchar('\n') != EOF)) if (putchar('\n') == EOF)
count++; return EOF;
else
count = EOF;
return count; return count + 1;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment