* [PATCH v2] remove-compiler-warning-in-mkimage
@ 2020-04-09 14:39 Michael Graichen
0 siblings, 0 replies; only message in thread
From: Michael Graichen @ 2020-04-09 14:39 UTC (permalink / raw)
To: barebox
Fixes a warning while compiling zynq_mkimage.c
scripts/zynq_mkimage.c:312:2: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
fread returns the number bytes read, if it is not equal to st_size some error has happend
Signed-off-by: Michael Graichen <michael.graichen@hotmail.com>
---
scripts/zynq_mkimage.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/scripts/zynq_mkimage.c b/scripts/zynq_mkimage.c
index 0a1c06947..a211b79c2 100644
--- a/scripts/zynq_mkimage.c
+++ b/scripts/zynq_mkimage.c
@@ -241,7 +241,7 @@ int main(int argc, char *argv[])
char *buf;
const char *infile = NULL, *outfile = NULL, *cfgfile = NULL;
struct stat st;
- int opt;
+ int opt, ret;
prgname = argv[0];
@@ -309,7 +309,12 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- fread(buf + IMAGE_OFFSET, sizeof(char), st.st_size, ifile);
+ ret = fread(buf + IMAGE_OFFSET, sizeof(char), st.st_size, ifile);
+
+ if(ret != st.st_size) {
+ fprintf(stderr, "Error while reading %s\n", infile);
+ exit(EXIT_FAILURE);
+ }
add_header(buf, st.st_size);
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-04-09 14:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-09 14:39 [PATCH v2] remove-compiler-warning-in-mkimage Michael Graichen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox