[PATCH] scripts: imx-image: add error handling for pwrite
Sascha Hauer
sha at pengutronix.de
Mon Mar 15 08:06:07 GMT 2021
On Fri, Mar 12, 2021 at 11:54:44AM +0100, Rouven Czerwinski wrote:
> 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(-)
Applied, thanks
Sascha
>
> 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 at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list