Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Nov 2022 12:35:48 GMT
From:      =?utf-8?Q?Dag-Erling=20Sm=C3=B8rgrav?= <des@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 1b9c55cf9a3a - stable/13 - apply: clean up error handling.
Message-ID:  <202211021235.2A2CZmZE081149@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202211021235.2A2CZmZE081149>