* [PATCH 0/1] x86: Fix warning: ignoring return value of 'fread'
@ 2010-08-26 0:07 Jean Sacren
2010-08-26 0:09 ` [PATCH 1/1] " Jean Sacren
0 siblings, 1 reply; 3+ messages in thread
From: Jean Sacren @ 2010-08-26 0:07 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Linux Arch Mailing List
Hi,
Jean Sacren (1):
x86: Fix warning: ignoring return value of 'fread'
arch/x86/boot/compressed/mkpiggy.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
--
Jean Sacren
Bring LAMP To People
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/1] x86: Fix warning: ignoring return value of 'fread'
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
2010-08-26 0:12 ` H. Peter Anvin
0 siblings, 1 reply; 3+ messages in thread
From: Jean Sacren @ 2010-08-26 0:09 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Linux Arch Mailing List
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] x86: Fix warning: ignoring return value of 'fread'
2010-08-26 0:09 ` [PATCH 1/1] " Jean Sacren
@ 2010-08-26 0:12 ` H. Peter Anvin
0 siblings, 0 replies; 3+ messages in thread
From: H. Peter Anvin @ 2010-08-26 0:12 UTC (permalink / raw)
To: Jean Sacren; +Cc: Linux Arch Mailing List
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-26 0:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).