aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordavidcunado-arm <david.cunado@arm.com>2018-03-22 06:17:37 +0000
committerGitHub <noreply@github.com>2018-03-22 06:17:37 +0000
commitfbdadd015dd89574cdc25e7edb3a589244dd4d73 (patch)
treecd78624db096bd6a7771ec17c095c6f446b87a08 /lib
parentff48086b32b84dfcbdfb803180fda65a4fa08386 (diff)
parent5ea2827734be3e8c1f620de47a9e01f41ca99e2f (diff)
downloadplatform_external_arm-trusted-firmware-fbdadd015dd89574cdc25e7edb3a589244dd4d73.tar.gz
platform_external_arm-trusted-firmware-fbdadd015dd89574cdc25e7edb3a589244dd4d73.tar.bz2
platform_external_arm-trusted-firmware-fbdadd015dd89574cdc25e7edb3a589244dd4d73.zip
Merge pull request #1311 from jonathanwright-ARM/jw/MISRA-EOF-usage
stdlib: remove comparison with EOF macro to comply with MISRA
Diffstat (limited to 'lib')
-rw-r--r--lib/stdlib/puts.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/stdlib/puts.c b/lib/stdlib/puts.c
index 693a6bff3..284cf8c52 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;
}