From 5ea2827734be3e8c1f620de47a9e01f41ca99e2f Mon Sep 17 00:00:00 2001 From: Jonathan Wright Date: Tue, 6 Mar 2018 16:23:28 +0000 Subject: 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: Jonathan Wright --- lib/stdlib/puts.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'lib/stdlib/puts.c') diff --git a/lib/stdlib/puts.c b/lib/stdlib/puts.c index 693a6bff..284cf8c5 100644 --- a/lib/stdlib/puts.c +++ b/lib/stdlib/puts.c @@ -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; } -- cgit v1.2.3