[PATCH] scripts: imx-image: add error handling for pwrite
Rouven Czerwinski
r.czerwinski at pengutronix.de
Fri Mar 12 10:54:44 GMT 2021
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 at pengutronix.de>
---
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
More information about the barebox
mailing list