[PATCH 1/1] x86: Fix warning: ignoring return value of 'fread'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



warning: ignoring return value of 'fread', declared with attribute
warn_unused_result

This fix facilitates fread() either it succeeds, or an error occurs or
the end of file is reached.

Signed-off-by: Jean Sacren <sakiwit@xxxxxxxxx>
---
 arch/x86/boot/compressed/mkpiggy.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/arch/x86/boot/compressed/mkpiggy.c b/arch/x86/boot/compressed/mkpiggy.c
index 5c22812..fac37c3 100644
--- a/arch/x86/boot/compressed/mkpiggy.c
+++ b/arch/x86/boot/compressed/mkpiggy.c
@@ -62,7 +62,10 @@ int main(int argc, char *argv[])
 	if (fseek(f, -4L, SEEK_END)) {
 		perror(argv[1]);
 	}
-	fread(&olen, sizeof olen, 1, f);
+
+	if (fread(&olen, sizeof olen, 1, f) < 1)
+		fprintf(stderr, "\nError in reading or end of file.\n");
+
 	ilen = ftell(f);
 	olen = getle32(&olen);
 	fclose(f);
-- 
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-arch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux