From nobody Fri Jan 07 13:30:50 2022 X-Original-To: dev-commits-src-all@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 DBE551940435; Fri, 7 Jan 2022 13:30:50 +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 4JVkcp3Y73z4hP1; Fri, 7 Jan 2022 13:30:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 592064423; Fri, 7 Jan 2022 13:30:50 +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 207DUobk030497; Fri, 7 Jan 2022 13:30:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 207DUoPu030496; Fri, 7 Jan 2022 13:30:50 GMT (envelope-from git) Date: Fri, 7 Jan 2022 13:30:50 GMT Message-Id: <202201071330.207DUoPu030496@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: 7c0170ab9ff2 - stable/13 - echo(1): Replace errexit() with err(3) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7c0170ab9ff21d958654468f3bd95acee2896a98 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641562250; 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=Y6a+8OfeOGSUAZFmy3Epjit1QRMy/SLo7Up0E2Lkpdo=; b=J84JEIbG11JkFYTatKs3Qo23Y/FPnJXFpe0gBftuG6zzdXU2gDSpYBnS2Qm94+hxxb6Apk LFPz3R0+h8WC5WQou3BRLw7qiqWci5FnDuUGbkKgkmSKIj4Dq9y05e/u0xS1+c7jx3fq3z lLXvmQMXpyzgRYqXGuQyt1XgSEH6dYc4Q5mSw2OR09AEeUHGy06yrzB86LMZOZdp7Kipvs liZz3KLcoVIfWQaAwX78U7kk+mkoSKIuIeXAZ3YLXqo+9Tc61QbCqJmNPTLwe+V3FngvxC /tajoqS49C+HuFoTMdoz+zqNTmRfrZU0l2KT0rnI+uXgrpSBfR6tu7YhkLnzWA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641562250; a=rsa-sha256; cv=none; b=bGVNUllLb2GVvJ04qNsZBvBQP5aSi1nje0eOz+zuy8GHgcQmfrNHLu+MQmf/XmNtHUcudU P6QaxnMB0UeJSItG0rQbo+M78ON1RPd1UJGt5GGCcFjKv8gyK5KCarb45vEfCxemm0UO/H 6pwl+7wzT0ItNHJPE6bKrWHNo4XeBTwe0Pwu4TXWTGDRmxNn5nACfq3VP2LZWskCx2LPxZ wSA9fx5waxtLX+6AIQJDIpa7IeveWUI0JRtpGdB3MmYrn9S2ylRdJjIIc3D8em3kX67JAO e5CdMQq75h9Kp+Agjf8yPMbBGaKLZUTwUpGwn+e8RbB1bwwigQ9yNGV984v5iA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=7c0170ab9ff21d958654468f3bd95acee2896a98 commit 7c0170ab9ff21d958654468f3bd95acee2896a98 Author: Hans Petter Selasky AuthorDate: 2021-11-09 21:09:46 +0000 Commit: Hans Petter Selasky CommitDate: 2022-01-07 13:12:12 +0000 echo(1): Replace errexit() with err(3) Differential revision: https://reviews.freebsd.org/D32501 Submitted by: christos@ Sponsored by: NVIDIA Networking (cherry picked from commit 4c537df51a16ce004b184010d306e550716f49ea) --- bin/echo/echo.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/bin/echo/echo.c b/bin/echo/echo.c index f56bd5b976d8..46796ad1a27d 100644 --- a/bin/echo/echo.c +++ b/bin/echo/echo.c @@ -55,23 +55,6 @@ __FBSDID("$FreeBSD$"); #include #include -/* - * Report an error and exit. - * Use it instead of err(3) to avoid linking-in stdio. - */ -static __dead2 void -errexit(const char *prog, const char *reason) -{ - char *errstr = strerror(errno); - write(STDERR_FILENO, prog, strlen(prog)); - write(STDERR_FILENO, ": ", 2); - write(STDERR_FILENO, reason, strlen(reason)); - write(STDERR_FILENO, ": ", 2); - write(STDERR_FILENO, errstr, strlen(errstr)); - write(STDERR_FILENO, "\n", 1); - exit(1); -} - int main(int argc, char *argv[]) { @@ -80,7 +63,6 @@ main(int argc, char *argv[]) struct iovec *iov, *vp; /* Elements to write, current element. */ char space[] = " "; char newline[] = "\n"; - char *progname = argv[0]; if (caph_limit_stdio() < 0 || caph_enter() < 0) err(1, "capsicum"); @@ -96,7 +78,7 @@ main(int argc, char *argv[]) veclen = (argc >= 2) ? (argc - 2) * 2 + 1 : 0; if ((vp = iov = malloc((veclen + 1) * sizeof(struct iovec))) == NULL) - errexit(progname, "malloc"); + err(1, "malloc"); while (argv[0] != NULL) { size_t len; @@ -135,7 +117,7 @@ main(int argc, char *argv[]) nwrite = (veclen > IOV_MAX) ? IOV_MAX : veclen; if (writev(STDOUT_FILENO, iov, nwrite) == -1) - errexit(progname, "write"); + err(1, "write"); iov += nwrite; veclen -= nwrite; }