From nobody Thu Jan 30 15:49:09 2025 X-Original-To: dev-commits-src-main@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 4YkNjx34J9z5lZ2x; Thu, 30 Jan 2025 15:49:09 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YkNjx2WwKz3WFH; Thu, 30 Jan 2025 15:49:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738252149; 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=VT2yzLmy9d0ST2+ZfiZaud/PeoLU5AM8LBsQEmBNCpY=; b=j5fb7gl2BuvjuSaAW9GnbYkrdW0LABE0eLVQau3v/GPZmgPkmdymjcconJcn/PLhjYlVv5 hGW8zIUMBWAK/1mMIEpNzlkVYgc8FjscHdS0/xVtGCQFq99O89McUOYQYORWcISUM+wiQa EzYDFo8FaeP+TFkNcurxLGlbVS2nBwXxQ6gp1SuRC9XZJU3jjpwRqt6vJehiunMoMZPXng wKzj7LQ7yVxSOss0g5c83UDiz8wPdOBa4BoMD72ChYJcsXfebOP+IFDl9/iq7GShADI3mk dVydJvbdhvZ3T+/h0AcDOKGTgXP/htkJWykh0MFeCLNSjl6Vwa9hBA5KpGNz+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738252149; 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=VT2yzLmy9d0ST2+ZfiZaud/PeoLU5AM8LBsQEmBNCpY=; b=Msd5KZayUya/5/HgCiGdEklejQ80I8U7xbzXqcP6ThOcl+Dg0WllLL8ebKd96ge7ULmNha ltfMIoIyBxqNVGIWELmwLrcfY0+f6VTupz9GwF112gQB1IumPdRMqtSlYVPfajuCfzk4SM OcuiYd0960b9W8H55x/rF11C+xG1BMDRG/c67ISO7+96rETtotAzrFOvRtaAIArogv7AxX aibkz7onchrBfMzHaRkegcDx6M42PNiVCVe8iCbLkQqA5ot2YJNGjOhhvNrSXti6/HFj3T cuNOYaRRPsXfNh0uLDyQrBV8tSdtsLsB07GB8EgW8FWHA+nhCigX7RgSaGRnvw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1738252149; a=rsa-sha256; cv=none; b=YBvxLpiRZgSmIVPAEEldgjDPketCsCI1+UJGHc0yXIqpdSA9Q1+kKejQccu75R6WMJdSXL CvtJDqLqQu2CQIw2tdZ3csfj16Jh9jHWQP6cJXWD9uU5lQ03CxavfJx9UpazSTeg1WbqOv fa8PQhlBx4jX1TSwc94ILwNzEXsbqCEG3z+iRtSkUvqF5jKcStYDrhVv2p8e0ANAREgPIw 1v1DHJWFLKP3nQul2rIzc3pCLVIXXEx+71hQtL4ucKJGkjQjChVA9joLHbALJItI4masli nBU9bEEmQ+Al5vUPw1Dp//dqrOgj3pWELp4grXceEFqoTxHDd+ELsFGTMZYiSg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YkNjx1wfrztYh; Thu, 30 Jan 2025 15:49:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50UFn9f8006388; Thu, 30 Jan 2025 15:49:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50UFn9vo006385; Thu, 30 Jan 2025 15:49:09 GMT (envelope-from git) Date: Thu, 30 Jan 2025 15:49:09 GMT Message-Id: <202501301549.50UFn9vo006385@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: de3deff65c5b - main - libiscsiutil: Add log_warnc() and log_errc() functions List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: de3deff65c5b407ab29b45780f2585b3bc24bbd6 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=de3deff65c5b407ab29b45780f2585b3bc24bbd6 commit de3deff65c5b407ab29b45780f2585b3bc24bbd6 Author: John Baldwin AuthorDate: 2025-01-30 15:15:39 +0000 Commit: John Baldwin CommitDate: 2025-01-30 15:15:39 +0000 libiscsiutil: Add log_warnc() and log_errc() functions These are similar to warnc() and errc() in that they take an explicit error code instead of using the value of the errno global. Reviewed by: mav, asomers Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48648 --- lib/libiscsiutil/libiscsiutil.h | 4 ++++ lib/libiscsiutil/log.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/libiscsiutil/libiscsiutil.h b/lib/libiscsiutil/libiscsiutil.h index 8da6ead73fce..c091c1d9753a 100644 --- a/lib/libiscsiutil/libiscsiutil.h +++ b/lib/libiscsiutil/libiscsiutil.h @@ -162,9 +162,13 @@ void log_set_peer_name(const char *name); void log_set_peer_addr(const char *addr); void log_err(int, const char *, ...) __dead2 __printflike(2, 3); +void log_errc(int, int, const char *, ...) + __dead2 __printflike(3, 4); void log_errx(int, const char *, ...) __dead2 __printflike(2, 3); void log_warn(const char *, ...) __printflike(1, 2); +void log_warnc(int, const char *, ...) + __printflike(2, 3); void log_warnx(const char *, ...) __printflike(1, 2); void log_debugx(const char *, ...) __printflike(1, 2); diff --git a/lib/libiscsiutil/log.c b/lib/libiscsiutil/log.c index a69c979c3cce..cead4ab2d709 100644 --- a/lib/libiscsiutil/log.c +++ b/lib/libiscsiutil/log.c @@ -152,6 +152,18 @@ log_err(int eval, const char *fmt, ...) exit(eval); } +void +log_errc(int eval, int code, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + log_common(LOG_CRIT, code, fmt, ap); + va_end(ap); + + exit(eval); +} + void log_errx(int eval, const char *fmt, ...) { @@ -174,6 +186,16 @@ log_warn(const char *fmt, ...) va_end(ap); } +void +log_warnc(int code, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + log_common(LOG_WARNING, code, fmt, ap); + va_end(ap); +} + void log_warnx(const char *fmt, ...) {