[master] 4b480b48d Refactor vut_error() into VUT_Error()
Poul-Henning Kamp
phk at FreeBSD.org
Mon Oct 22 07:50:19 UTC 2018
commit 4b480b48d98e76d03ab5b50448467b8928ccfff0
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Oct 22 06:25:28 2018 +0000
Refactor vut_error() into VUT_Error()
diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c
index b02644a81..8b3f6ed0e 100644
--- a/lib/libvarnishapi/vut.c
+++ b/lib/libvarnishapi/vut.c
@@ -110,32 +110,23 @@ vut_dispatch(struct VSL_data *vsl, struct VSL_transaction * const trans[],
return (i);
}
-//lint -sem(vut_error, r_no)
-static void v_noreturn_ v_matchproto_(VUT_error_f)
-vut_error(struct VUT *vut, int status, const char *fmt, va_list ap)
-{
-
- CHECK_OBJ_NOTNULL(vut, VUT_MAGIC);
- AN(fmt);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
-
- exit(status);
-}
-
void
VUT_Error(struct VUT *vut, int status, const char *fmt, ...)
{
va_list ap;
CHECK_OBJ_NOTNULL(vut, VUT_MAGIC);
- AN(vut->error_f);
AN(status);
va_start(ap, fmt);
- vut->error_f(vut, status, fmt, ap);
+ if (vut->error_f != NULL) {
+ vut->error_f(vut, status, fmt, ap);
+ } else {
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+ }
va_end(ap);
- exit(2);
+ exit(status);
}
int
@@ -231,7 +222,6 @@ VUT_Init(const char *progname, int argc, char * const *argv,
vut->progname = progname;
vut->g_arg = VSL_g_vxid;
vut->k_arg = -1;
- vut->error_f = vut_error;
AZ(vut->vsl);
vut->vsl = VSL_New();
AN(vut->vsl);
@@ -306,7 +296,8 @@ VUT_Setup(struct VUT *vut)
VUT_Error(vut, 1, "PID file already created");
pfh = VPF_Open(vut->P_arg, 0644, NULL);
if (pfh == NULL)
- VUT_Error(vut, 1, "%s: %s", vut->P_arg, strerror(errno));
+ VUT_Error(vut, 1,
+ "%s: %s", vut->P_arg, strerror(errno));
}
/* Daemon mode */
More information about the varnish-commit
mailing list