From: "H. Peter Anvin" <hpa@linux.intel.com>
To: Jean Sacren <sakiwit@gmail.com>
Cc: Linux Arch Mailing List <linux-arch@vger.kernel.org>
Subject: Re: [PATCH 1/1] x86: Fix warning: ignoring return value of 'fread'
Date: Wed, 25 Aug 2010 17:12:59 -0700 [thread overview]
Message-ID: <4C75B18B.5070803@linux.intel.com> (raw)
In-Reply-To: <20100826000959.GA7220@mail.gmail.com>
On 08/25/2010 05:09 PM, Jean Sacren wrote:
> 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);
I usually prefer the style:
if (fread(&olen, 1, sizeof olen, f) != sizeof olen)
... for consistency with plain write(). It's a minor nitpick, though.
-hpa
prev parent reply other threads:[~2010-08-26 0:13 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 ` [PATCH 1/1] " Jean Sacren
2010-08-26 0:12 ` H. Peter Anvin [this message]
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=4C75B18B.5070803@linux.intel.com \
--to=hpa@linux.intel.com \
--cc=linux-arch@vger.kernel.org \
--cc=sakiwit@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).