git: 1b9c55cf9a3a - stable/13 - apply: clean up error handling.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 02 Nov 2022 12:35:48 UTC
The branch stable/13 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=1b9c55cf9a3a3c65f69bbeab6bc238e805a6d693 commit 1b9c55cf9a3a3c65f69bbeab6bc238e805a6d693 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-11-02 09:37:24 +0000 apply: clean up error handling. Sponsored by: Klara, Inc. (cherry picked from commit 441202c00bdf6edbf6b6bc1b1923bebd8e2d8e45) --- 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)