git: 441202c00bdf - main - apply: clean up error handling.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 08 Aug 2022 19:07:15 UTC
The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=441202c00bdf6edbf6b6bc1b1923bebd8e2d8e45 commit 441202c00bdf6edbf6b6bc1b1923bebd8e2d8e45 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2022-08-08 19:06:35 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2022-08-08 19:06:35 +0000 apply: clean up error handling. Sponsored by: Klara, Inc. --- usr.bin/apply/apply.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/usr.bin/apply/apply.c b/usr.bin/apply/apply.c index 3cba41c37e64..fc90af6d3dff 100644 --- a/usr.bin/apply/apply.c +++ b/usr.bin/apply/apply.c @@ -176,23 +176,24 @@ main(int argc, char *argv[]) */ for (rval = 0; argc > nargs; argc -= nargs, argv += nargs) { sbuf_clear(cmdbuf); - sbuf_cat(cmdbuf, "exec "); + if (sbuf_cat(cmdbuf, "exec ") != 0) + err(1, "sbuf"); /* Expand command argv references. */ for (p = cmd; *p != '\0'; ++p) { if (ISMAGICNO(p)) { - if (sbuf_cat(cmdbuf, argv[(++p)[0] - '0']) - == -1) - errc(1, ENOMEM, "sbuf"); + if (sbuf_cat(cmdbuf, argv[*++p - '0']) != 0) + err(1, "sbuf"); } else { - if (sbuf_putc(cmdbuf, *p) == -1) - errc(1, ENOMEM, "sbuf"); + if (sbuf_putc(cmdbuf, *p) != 0) + err(1, "sbuf"); } if (sbuf_len(cmdbuf) > arg_max) errc(1, E2BIG, NULL); } /* Terminate the command string. */ - sbuf_finish(cmdbuf); + if (sbuf_finish(cmdbuf) != 0) + err(1, "sbuf"); /* Run the command. */ if (debug)