mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Graichen <michael.graichen@hotmail.com>
To: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: [PATCH v2] remove-compiler-warning-in-mkimage
Date: Thu, 9 Apr 2020 14:39:44 +0000	[thread overview]
Message-ID: <DB7PR02MB433206871367AB145225BB20ABC10@DB7PR02MB4332.eurprd02.prod.outlook.com> (raw)

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

                 reply	other threads:[~2020-04-09 14:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=DB7PR02MB433206871367AB145225BB20ABC10@DB7PR02MB4332.eurprd02.prod.outlook.com \
    --to=michael.graichen@hotmail.com \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox