[PATCH] scripts: imx-image: add error handling for pwrite

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

 



Fixes the following compiler warning:

  scripts/imx/imx-image.c: In function ‘main’:
  scripts/imx/imx-image.c:988:3: warning: ignoring return value of ‘pwrite’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    988 |   pwrite(outfd, bb_header, sizeof_bb_header, 0);
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Rouven Czerwinski <r.czerwinski@xxxxxxxxxxxxxx>
---
 scripts/imx/imx-image.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index f5e89d07a6..57d777a065 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -984,8 +984,13 @@ int main(int argc, char *argv[])
 		xwrite(outfd, buf, header_len);
 	}
 
-	if (add_barebox_header)
-		pwrite(outfd, bb_header, sizeof_bb_header, 0);
+	if (add_barebox_header) {
+		ret = pwrite(outfd, bb_header, sizeof_bb_header, 0);
+		if (ret < 0) {
+			fprintf(stderr, "pwrite failed: %s\n", strerror(errno));
+			exit(1);
+		}
+	}
 
 	xwrite(outfd, infile, insize);
 
-- 
2.30.1


_______________________________________________
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