aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2025-01-30 15:15:39 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2025-01-30 15:15:39 +0000
commitde3deff65c5b407ab29b45780f2585b3bc24bbd6 (patch)
tree3f6e73be926c12d0ca3a19cd0abd0018e9b0a9f2 /lib
parenta55197c3228cd015ebc8218afbc938ef09191a98 (diff)
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
Diffstat (limited to 'lib')
-rw-r--r--lib/libiscsiutil/libiscsiutil.h4
-rw-r--r--lib/libiscsiutil/log.c22
2 files changed, 26 insertions, 0 deletions
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
@@ -153,6 +153,18 @@ log_err(int eval, const char *fmt, ...)
}
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, ...)
{
va_list ap;
@@ -175,6 +187,16 @@ log_warn(const char *fmt, ...)
}
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, ...)
{
va_list ap;