[PATCH 3/7] Zedboard fix compiler warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

diff --git a/scripts/zynq_mkimage.c b/scripts/zynq_mkimage.c
index 0a1c06947..22bd40b7e 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);
 
_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux