From nobody Wed Nov 2 12:35:48 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4N2RFK0NLzz4h4P3; Wed, 2 Nov 2022 12:35:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N2RFJ6p1Lz43Zs; Wed, 2 Nov 2022 12:35:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667392549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IeQutbHl32RhoSZrf5FOlo3Chbe9ameO6n9Jgh754CA=; b=lTdIogbVOS2xvr3ShtaAoSsQZEA3Z2XHn/mIqr5wwZnynhMXUz04qsCnIwnrb3mYJMVp19 AYDQaxdpdMbbrNcSsIaJMFQ8BHzB/n9JJxIODw1vS+HAQtFTAMCtijJEIb/rGCWy7K4h1o br0dGDCFbLvhdY5v1nIOOWqP/Ef+DXN8pt6g53zvX8ImoPrKWnwGcEMxWmlp2lyDgkobiX tpUah8p7c3o1WF9SO65cZ04nTPDTlsy98crhPbT1K8e3amgZT8CdNZWUfCWwbqBbKXTjgf JlpHzTYaw+dt4ZR4U2XVN3wavCyaVxX3xLm/6r9cLxnm7bjRu4ENjdR5OXUASw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N2RFJ5tNhzwfT; Wed, 2 Nov 2022 12:35:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2A2CZms7081150; Wed, 2 Nov 2022 12:35:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2A2CZmZE081149; Wed, 2 Nov 2022 12:35:48 GMT (envelope-from git) Date: Wed, 2 Nov 2022 12:35:48 GMT Message-Id: <202211021235.2A2CZmZE081149@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Dag-Erling=20Sm=C3=B8rgrav?= Subject: git: 1b9c55cf9a3a - stable/13 - apply: clean up error handling. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1b9c55cf9a3a3c65f69bbeab6bc238e805a6d693 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667392549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IeQutbHl32RhoSZrf5FOlo3Chbe9ameO6n9Jgh754CA=; b=WTBK/G+8OudbKeQJAEpQndfAemTioJLdJR+gMmGFQf0q73Zn7xJ2AUvsp5NP+3OCosMnbe AjHmefM4e+YGA4ZAI2xXfJsbM3ACKAkd8PdHKCAcgY292Agq3CPjR5OL7olbp/hMAjjXCK aW2HP/W4ZBRYA3OnlGZ5xAXq9rz1nIIOU+PYpm/wyK0Io+BFSRGC9stVHg8/cELv39MVI/ jytH+8z7c1AbYLibvWCmywWS/YOQ6nFMkOESIFNjuo4E5biPo7Gw6dhO+6iEEwgkTeZgXs 8RzkwZYZvfHcOD5KyRgzMeVmTy3WXrXM3onUpdvk7XwWE/7wejpnBwL9iGpddg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667392549; a=rsa-sha256; cv=none; b=q3ora2QgfpMId9g4P562P6RJTqsJLG48PMDjLgrdM+u7oBXPCxcOkg9NkSaX44uGbkv1+Q juygZ43VF6zYiQghJZdCCKok7d2REuoMLXESibOFoXwDw1cOckKqteNXnPEXKEZocoI3hs lB0gZiKIsDX6+yIjw6bz0GWqkCb3ixibgsfcDekRH1N+XgAJ94eExV7XMbhGejRbqq1p87 OhiOrUEv4NAXW57w4O/BZm3PhEuNpYIyl0l85nZc/isZJny0EM3Yg+mqiHONRaHESJ7kAo 17bsK8ma9LGtTsjYLv/TEfngewSCJgv78c+5qzv3BL12Q3H01VUr58U6HefZeg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N 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 AuthorDate: 2022-08-08 19:06:35 +0000 Commit: Dag-Erling Smørgrav 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)