All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean Sacren <sakiwit@gmail.com>
To: "H. Peter Anvin" <hpa@linux.intel.com>
Cc: Linux Arch Mailing List <linux-arch@vger.kernel.org>
Subject: [PATCH 1/1] x86: Fix warning: ignoring return value of 'fread'
Date: Wed, 25 Aug 2010 18:09:59 -0600	[thread overview]
Message-ID: <20100826000959.GA7220@mail.gmail.com> (raw)
In-Reply-To: <20100826000739.GA7216@mail.gmail.com>

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@gmail.com>
---
 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

  reply	other threads:[~2010-08-26  0:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-26  0:07 [PATCH 0/1] x86: Fix warning: ignoring return value of 'fread' Jean Sacren
2010-08-26  0:09 ` Jean Sacren [this message]
2010-08-26  0:12   ` [PATCH 1/1] " H. Peter Anvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100826000959.GA7220@mail.gmail.com \
    --to=sakiwit@gmail.com \
    --cc=hpa@linux.intel.com \
    --cc=linux-arch@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.