Instead of using errno as a hidden argument to vfatal(), make it an 
_actual_ argument named 'code', ala the errc/warnc family, and rename it 
to vfatalc() to match the pattern set.

ok?

Philip Guenther

Index: log.c
===================================================================
RCS file: /data/src/openbsd/src/usr.sbin/vmd/log.c,v
retrieving revision 1.3
diff -u -p -r1.3 log.c
--- log.c       12 Oct 2016 11:47:34 -0000      1.3
+++ log.c       16 Oct 2016 21:17:40 -0000
@@ -165,11 +165,10 @@ log_debug(const char *emsg, ...)
 }
 
 static void
-vfatal(const char *emsg, va_list ap)
+vfatalc(int code, const char *emsg, va_list ap)
 {
        static char     s[BUFSIZ];
        const char      *sep;
-       int              saved_errno = errno;
 
        if (emsg != NULL) {
                (void)vsnprintf(s, sizeof(s), emsg, ap);
@@ -178,9 +177,9 @@ vfatal(const char *emsg, va_list ap)
                s[0] = '\0';
                sep = "";
        }
-       if (saved_errno)
+       if (code)
                logit(LOG_CRIT, "%s: %s%s%s",
-                   log_procname, s, sep, strerror(saved_errno));
+                   log_procname, s, sep, strerror(code));
        else
                logit(LOG_CRIT, "%s%s%s", log_procname, sep, s);
 }
@@ -191,7 +190,7 @@ fatal(const char *emsg, ...)
        va_list ap;
 
        va_start(ap, emsg);
-       vfatal(emsg, ap);
+       vfatalc(errno, emsg, ap);
        va_end(ap);
        exit(1);
 }
@@ -201,9 +200,8 @@ fatalx(const char *emsg, ...)
 {
        va_list ap;
 
-       errno = 0;
        va_start(ap, emsg);
-       vfatal(emsg, ap);
+       vfatalc(0, emsg, ap);
        va_end(ap);
        exit(1);
 }

Reply via email to