[master] 43935f471 wrap errno.h / strerror() in a v* variant (no inline)

Nils Goroll nils.goroll at uplex.de
Mon Nov 5 18:01:05 UTC 2018


commit 43935f471e968a9bf38189f916a8d6c2c858c097
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Nov 5 18:53:06 2018 +0100

    wrap errno.h / strerror() in a v* variant (no inline)
    
    (at leat on solaris) strerror() itself may fail for an out-of-memory
    condition (because the localization code contains memory
    allocations). In order to handle this situation, we need to save the
    original errno because strerror() may also set errno.
    
    Fixes #2815

diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c
index 69f319509..d909ebd24 100644
--- a/bin/varnishadm/varnishadm.c
+++ b/bin/varnishadm/varnishadm.c
@@ -49,7 +49,6 @@
 #  error missing readline.h - this should have got caught in configure
 #endif
 
-#include <errno.h>
 #include <math.h>
 #include <fcntl.h>
 #include <poll.h>
diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index c0d44850f..bc3c1360b 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -33,7 +33,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <stdlib.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
@@ -526,7 +525,7 @@ vca_accept_task(struct worker *wrk, void *arg)
 
 			VSL(SLT_SessError, 0, "%s %s %s %d %d %s",
 			    wa.acceptlsock->name, laddr, lport,
-			    ls->sock, i, strerror(i));
+			    ls->sock, i, vstrerror(i));
 			(void)Pool_TrySumstat(wrk);
 			continue;
 		}
@@ -650,12 +649,12 @@ ccf_start(struct cli *cli, const char * const *av, void *priv)
 			if (i)
 				VSL(SLT_Error, 0,
 				    "Kernel TCP Fast Open: sock=%d, ret=%d %s",
-				    ls->sock, i, strerror(errno));
+				    ls->sock, i, vstrerror(errno));
 		}
 		if (listen(ls->sock, cache_param->listen_depth)) {
 			VCLI_SetResult(cli, CLIS_CANT);
 			VCLI_Out(cli, "Listen failed on socket '%s': %s",
-			    ls->endpoint, strerror(errno));
+			    ls->endpoint, vstrerror(errno));
 			return;
 		}
 		vca_tcp_opt_set(ls->sock, ls->uds, 1);
@@ -665,7 +664,7 @@ ccf_start(struct cli *cli, const char * const *av, void *priv)
 			if (i)
 				VSL(SLT_Error, 0,
 				    "Kernel filtering: sock=%d, ret=%d %s",
-				    ls->sock, i, strerror(errno));
+				    ls->sock, i, vstrerror(errno));
 		}
 	}
 
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index c714af99f..f1426f618 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -33,7 +33,6 @@
 #include "config.h"
 
 #include <stdlib.h>
-#include <errno.h>
 
 #include "cache_varnishd.h"
 
@@ -154,7 +153,7 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo,
 		VBE_Connect_Error(bp->vsc, err);
 		VSLb(bo->vsl, SLT_FetchError,
 		     "backend %s: fail errno %d (%s)",
-		     VRT_BACKEND_string(bp->director), err, strerror(err));
+		     VRT_BACKEND_string(bp->director), err, vstrerror(err));
 		VSC_C_main->backend_fail++;
 		bo->htc = NULL;
 		return (NULL);
diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c
index 899847c81..1537c9de7 100644
--- a/bin/varnishd/cache/cache_backend_probe.c
+++ b/bin/varnishd/cache/cache_backend_probe.c
@@ -39,7 +39,6 @@
 
 #include <poll.h>
 #include <stdio.h>
-#include <errno.h>
 #include <string.h>
 #include <stdlib.h>
 
@@ -236,11 +235,11 @@ vbp_write(struct vbp_target *vt, int *sock, const void *buf, size_t len)
 		if (i < 0) {
 			vt->err_xmit |= 1;
 			bprintf(vt->resp_buf, "Write error %d (%s)",
-				errno, strerror(errno));
+				errno, vstrerror(errno));
 		} else {
 			bprintf(vt->resp_buf,
 				"Short write (%d/%zu) error %d (%s)",
-				i, len, errno, strerror(errno));
+				i, len, errno, vstrerror(errno));
 		}
 		VTCP_close(sock);
 		return (-1);
@@ -289,7 +288,7 @@ vbp_poke(struct vbp_target *vt)
 
 	s = VTP_Open(vt->tcp_pool, t_end - t_now, (const void **)&sa, &err);
 	if (s < 0) {
-		bprintf(vt->resp_buf, "Open error %d (%s)", err, strerror(err));
+		bprintf(vt->resp_buf, "Open error %d (%s)", err, vstrerror(err));
 		Lck_Lock(&vbp_mtx);
 		if (vt->backend)
 			VBE_Connect_Error(vt->backend->vsc, err);
@@ -355,7 +354,7 @@ vbp_poke(struct vbp_target *vt)
 		if (i == 0) {
 			vt->err_recv |= 1;
 			bprintf(vt->resp_buf, "Poll error %d (%s)",
-				errno, strerror(errno));
+				errno, vstrerror(errno));
 			VTCP_close(&s);
 			return;
 		}
@@ -374,7 +373,7 @@ vbp_poke(struct vbp_target *vt)
 		if (i <= 0) {
 			if (i < 0)
 				bprintf(vt->resp_buf, "Read error %d (%s)",
-					errno, strerror(errno));
+					errno, vstrerror(errno));
 			break;
 		}
 		rlen += i;
diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c
index b1f993dbf..81ad5535f 100644
--- a/bin/varnishd/cache/cache_esi_fetch.c
+++ b/bin/varnishd/cache/cache_esi_fetch.c
@@ -30,7 +30,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <stdlib.h>
 
 #include "cache_varnishd.h"
diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c
index 1e6e689ac..30cbbab4a 100644
--- a/bin/varnishd/cache/cache_lck.c
+++ b/bin/varnishd/cache/cache_lck.c
@@ -37,7 +37,6 @@
 
 #include "cache_varnishd.h"
 
-#include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
 
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 8282ed814..be6dd70f6 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -30,7 +30,6 @@
 #include "config.h"
 
 #include <execinfo.h>
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
@@ -667,7 +666,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
 	pan_backtrace(pan_vsb);
 
 	if (err)
-		VSB_printf(pan_vsb, "errno = %d (%s)\n", err, strerror(err));
+		VSB_printf(pan_vsb, "errno = %d (%s)\n", err, vstrerror(err));
 
 	q = THR_GetName();
 	if (q != NULL)
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index fede8e0ae..4d074747b 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -38,7 +38,6 @@
 
 #include "cache_varnishd.h"
 
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c
index e4db8158f..d57949a95 100644
--- a/bin/varnishd/cache/cache_shmlog.c
+++ b/bin/varnishd/cache/cache_shmlog.c
@@ -31,7 +31,6 @@
 
 #include "cache_varnishd.h"
 
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/bin/varnishd/cache/cache_tcp_pool.c b/bin/varnishd/cache/cache_tcp_pool.c
index 5a04eb5aa..59725b142 100644
--- a/bin/varnishd/cache/cache_tcp_pool.c
+++ b/bin/varnishd/cache/cache_tcp_pool.c
@@ -31,7 +31,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <stdlib.h>
 
 #include "cache_varnishd.h"
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 17179fec0..02af16289 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -30,7 +30,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <dlfcn.h>
 #include <fnmatch.h>
 #include <stdio.h>
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 58186b2eb..0c28ba29e 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -659,7 +659,7 @@ VRT_synth_page(VRT_CTX, const char *str, ...)
 			p = "(null)";
 		if (VSB_cat(vsb, p)) {
 			VRT_fail(ctx, "synthetic(): %s",
-				 strerror(VSB_error(vsb)));
+				 vstrerror(VSB_error(vsb)));
 			break;
 		}
 		p = va_arg(ap, const char *);
diff --git a/bin/varnishd/cache/cache_vrt_filter.c b/bin/varnishd/cache/cache_vrt_filter.c
index 23eb919a3..b74ceb318 100644
--- a/bin/varnishd/cache/cache_vrt_filter.c
+++ b/bin/varnishd/cache/cache_vrt_filter.c
@@ -30,7 +30,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c
index 62f42ff45..4147e211c 100644
--- a/bin/varnishd/cache/cache_vrt_vcl.c
+++ b/bin/varnishd/cache/cache_vrt_vcl.c
@@ -30,7 +30,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index 4d546ffd3..48672a9ea 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -52,7 +52,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <stdlib.h>
 
 #include "cache_varnishd.h"
@@ -453,7 +452,7 @@ pool_breed(struct pool *qp)
 
 	if (pthread_create(&tp, &tp_attr, pool_thread, pi)) {
 		VSL(SLT_Debug, 0, "Create worker thread failed %d %s",
-		    errno, strerror(errno));
+		    errno, vstrerror(errno));
 		Lck_Lock(&pool_mtx);
 		VSC_C_main->threads_failed++;
 		Lck_Unlock(&pool_mtx);
diff --git a/bin/varnishd/common/common_vsc.c b/bin/varnishd/common/common_vsc.c
index 7beb9036d..ea1d0049c 100644
--- a/bin/varnishd/common/common_vsc.c
+++ b/bin/varnishd/common/common_vsc.c
@@ -29,7 +29,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
diff --git a/bin/varnishd/common/common_vsmw.c b/bin/varnishd/common/common_vsmw.c
index 339394b58..4e54a4aea 100644
--- a/bin/varnishd/common/common_vsmw.c
+++ b/bin/varnishd/common/common_vsmw.c
@@ -34,7 +34,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <fcntl.h>
 #include <stdarg.h>
 #include <stdio.h>
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index b8e3e876f..d8318b444 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -32,7 +32,6 @@
 #include "cache/cache_varnishd.h"
 #include "cache/cache_filter.h"
 
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -115,7 +114,7 @@ V1F_SendReq(struct worker *wrk, struct busyobj *bo, uint64_t *ctr_hdrbytes,
 			assert(i < 0);
 			VSLb(bo->vsl, SLT_FetchError,
 			    "req.body read error: %d (%s)",
-			    errno, strerror(errno));
+			    errno, vstrerror(errno));
 			bo->req->doclose = SC_RX_BODY;
 		}
 		if (do_chunked)
@@ -134,7 +133,7 @@ V1F_SendReq(struct worker *wrk, struct busyobj *bo, uint64_t *ctr_hdrbytes,
 
 	if (j != 0 || i < 0) {
 		VSLb(bo->vsl, SLT_FetchError, "backend write error: %d (%s)",
-		    errno, strerror(errno));
+		    errno, vstrerror(errno));
 		VSLb_ts_busyobj(bo, "Bereq", W_TIM_real(wrk));
 		htc->doclose = SC_TX_ERROR;
 		return (-1);
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index b339339f5..a6693f662 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -35,7 +35,6 @@
 
 #include "cache/cache_varnishd.h"
 
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c
index a7fc994fe..c8352af54 100644
--- a/bin/varnishd/http1/cache_http1_line.c
+++ b/bin/varnishd/http1/cache_http1_line.c
@@ -42,7 +42,6 @@
 #include <sys/uio.h>
 #include "cache/cache_varnishd.h"
 
-#include <errno.h>
 #include <stdio.h>
 
 #include "cache_http1.h"
@@ -232,7 +231,7 @@ V1L_Flush(const struct worker *wrk)
 			v1l->werr++;
 			VSLb(v1l->vsl, SLT_Debug,
 			    "Write error, retval = %zd, len = %zd, errno = %s",
-			    i, v1l->liov, strerror(errno));
+			    i, v1l->liov, vstrerror(errno));
 		}
 	}
 	v1l->liov = 0;
diff --git a/bin/varnishd/http1/cache_http1_vfp.c b/bin/varnishd/http1/cache_http1_vfp.c
index 36228cc44..736febf85 100644
--- a/bin/varnishd/http1/cache_http1_vfp.c
+++ b/bin/varnishd/http1/cache_http1_vfp.c
@@ -35,7 +35,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <inttypes.h>
 
 #include "cache/cache_varnishd.h"
@@ -77,7 +76,7 @@ v1f_read(const struct vfp_ctx *vc, struct http_conn *htc, void *d, ssize_t len)
 		if (i < 0) {
 			// XXX: VTCP_Assert(i); // but also: EAGAIN
 			VSLb(vc->wrk->vsl, SLT_FetchError,
-			    "%s", strerror(errno));
+			    "%s", vstrerror(errno));
 			return (i);
 		}
 	}
diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c
index ce114d390..932a5b93f 100644
--- a/bin/varnishd/http2/cache_http2_session.c
+++ b/bin/varnishd/http2/cache_http2_session.c
@@ -31,7 +31,6 @@
 
 #include "cache/cache_varnishd.h"
 
-#include <errno.h>
 #include <stdio.h>
 
 #include "cache/cache_transport.h"
@@ -263,7 +262,7 @@ h2_ou_session(struct worker *wrk, struct h2_sess *h2,
 	sz = write(h2->sess->fd, h2_resp_101, strlen(h2_resp_101));
 	if (sz != strlen(h2_resp_101)) {
 		VSLb(h2->vsl, SLT_Debug, "H2: Upgrade: Error writing 101"
-		    " response: %s\n", strerror(errno));
+		    " response: %s\n", vstrerror(errno));
 		return (h2_ou_rel(wrk, req));
 	}
 
diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c
index fbf7f2619..cd2794612 100644
--- a/bin/varnishd/mgt/mgt_acceptor.c
+++ b/bin/varnishd/mgt/mgt_acceptor.c
@@ -35,7 +35,6 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <sys/stat.h>
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -133,7 +132,7 @@ MAC_reopen_sockets(void)
 			fail = err;
 		MGT_Complain(C_ERR,
 		    "Could not reopen listen socket %s: %s",
-		    ls->endpoint, strerror(err));
+		    ls->endpoint, vstrerror(err));
 	}
 	return fail;
 }
@@ -167,7 +166,7 @@ mk_listen_sock(const struct listen_arg *la, const struct suckaddr *sa)
 		FREE_OBJ(ls);
 		if (fail != EAFNOSUPPORT)
 			ARGV_ERR("Could not get socket %s: %s\n",
-			    la->endpoint, strerror(fail));
+			    la->endpoint, vstrerror(fail));
 		return(NULL);
 	}
 	return(ls);
@@ -330,7 +329,7 @@ MAC_Arg(const char *spec)
 					 val);
 			if (errno)
 				ARGV_ERR("Cannot parse mode sub-arg %s in -a: "
-					 "%s\n", val, strerror(errno));
+					 "%s\n", val, vstrerror(errno));
 			if (m <= 0 || m > 0777)
 				ARGV_ERR("Mode sub-arg %s out of range in -a\n",
 					 val);
diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c
index 16050b33a..8617bfdaf 100644
--- a/bin/varnishd/mgt/mgt_child.c
+++ b/bin/varnishd/mgt/mgt_child.c
@@ -34,7 +34,6 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
-#include <errno.h>
 #include <fcntl.h>
 #include <poll.h>
 #include <signal.h>
@@ -607,7 +606,7 @@ MCH_Cli_Fail(void)
 		    " killed it.", (intmax_t)child_pid);
 	else
 		MGT_Complain(C_ERR, "Failed to kill child with PID %jd: %s",
-		    (intmax_t)child_pid, strerror(errno));
+		    (intmax_t)child_pid, vstrerror(errno));
 }
 
 /*=====================================================================
diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c
index 3677eb620..ed38683de 100644
--- a/bin/varnishd/mgt/mgt_cli.c
+++ b/bin/varnishd/mgt/mgt_cli.c
@@ -34,7 +34,6 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#include <errno.h>
 #include <fcntl.h>
 #include <poll.h>
 #include <stdarg.h>
@@ -284,7 +283,7 @@ mcf_auth(struct cli *cli, const char *const *av, void *priv)
 	fd = open(secret_file, O_RDONLY);
 	if (fd < 0) {
 		VCLI_Out(cli, "Cannot open secret file (%s)\n",
-		    strerror(errno));
+		    vstrerror(errno));
 		VCLI_SetResult(cli, CLIS_CANT);
 		VJ_master(JAIL_MASTER_LOW);
 		return;
@@ -593,7 +592,7 @@ Marg_connect(const struct vev *e, int what)
 	M_fd = VTCP_connected(M_fd);
 	if (M_fd < 0) {
 		MGT_Complain(C_INFO, "Could not connect to CLI-master: %s",
-			strerror(errno));
+			vstrerror(errno));
 		ma = VTAILQ_FIRST(&m_addr_list);
 		AN(ma);
 		VTAILQ_REMOVE(&m_addr_list, ma, list);
diff --git a/bin/varnishd/mgt/mgt_jail.c b/bin/varnishd/mgt/mgt_jail.c
index d8d7dc993..a46a366f8 100644
--- a/bin/varnishd/mgt/mgt_jail.c
+++ b/bin/varnishd/mgt/mgt_jail.c
@@ -31,7 +31,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -150,18 +149,18 @@ VJ_make_workdir(const char *dname)
 		VJ_master(JAIL_MASTER_FILE);
 		if (mkdir(dname, 0755) < 0 && errno != EEXIST)
 			ARGV_ERR("Cannot create working directory '%s': %s\n",
-				 dname, strerror(errno));
+				 dname, vstrerror(errno));
 	}
 
 	if (chdir(dname) < 0)
 		ARGV_ERR("Cannot change to working directory '%s': %s\n",
-		    dname, strerror(errno));
+		    dname, vstrerror(errno));
 
 	i = open("_.testfile", O_RDWR|O_CREAT|O_EXCL, 0600);
 	if (i < 0)
 		ARGV_ERR("Cannot create test-file in %s (%s)\n"
 		    "Check permissions (or delete old directory)\n",
-		    dname, strerror(errno));
+		    dname, vstrerror(errno));
 	closefd(&i);
 	AZ(unlink("_.testfile"));
 	VJ_master(JAIL_MASTER_LOW);
@@ -184,11 +183,11 @@ VJ_make_subdir(const char *dname, const char *what, struct vsb *vsb)
 		if (vsb != NULL) {
 			VSB_printf(vsb,
 			    "Cannot create %s directory '%s': %s\n",
-			    what, dname, strerror(e));
+			    what, dname, vstrerror(e));
 		} else {
 			MGT_Complain(C_ERR,
 			    "Cannot create %s directory '%s': %s",
-			    what, dname, strerror(e));
+			    what, dname, vstrerror(e));
 		}
 		return (1);
 	}
diff --git a/bin/varnishd/mgt/mgt_jail_solaris.c b/bin/varnishd/mgt/mgt_jail_solaris.c
index dc1921297..f594eaede 100644
--- a/bin/varnishd/mgt/mgt_jail_solaris.c
+++ b/bin/varnishd/mgt/mgt_jail_solaris.c
@@ -207,7 +207,6 @@
 
 #ifdef HAVE_SETPPRIV
 
-#include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -395,7 +394,7 @@ vjs_setup(enum jail_gen_e jge)
 		MGT_Complain(C_SECURITY,
 		    "Solaris Jail warning: "
 		    " vjs_setup - priv_allocset failed: errno=%d (%s)",
-		    errno, strerror(errno));
+		    errno, vstrerror(errno));
 		return;
 	}
 
@@ -459,7 +458,7 @@ vjs_waive(enum jail_gen_e jge)
 		MGT_Complain(C_SECURITY,
 		    "Solaris Jail warning: "
 		    " vjs_waive - priv_allocset failed: errno=%d (%s)",
-		    errno, strerror(errno));
+		    errno, vstrerror(errno));
 		return;
 	}
 
diff --git a/bin/varnishd/mgt/mgt_jail_unix.c b/bin/varnishd/mgt/mgt_jail_unix.c
index f91cf24b9..cc3aeb199 100644
--- a/bin/varnishd/mgt/mgt_jail_unix.c
+++ b/bin/varnishd/mgt/mgt_jail_unix.c
@@ -30,7 +30,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <fcntl.h>
 #include <grp.h>
 #include <pwd.h>
@@ -253,11 +252,11 @@ vju_make_subdir(const char *dname, const char *what, struct vsb *vsb)
 		if (vsb != NULL) {
 			VSB_printf(vsb,
 			    "Cannot create %s directory '%s': %s\n",
-			    what, dname, strerror(e));
+			    what, dname, vstrerror(e));
 		} else {
 			MGT_Complain(C_ERR,
 			    "Cannot create %s directory '%s': %s",
-			    what, dname, strerror(e));
+			    what, dname, vstrerror(e));
 		}
 		return (1);
 	}
@@ -277,7 +276,7 @@ vju_make_workdir(const char *dname, const char *what, struct vsb *vsb)
 
 	if (mkdir(dname, 0755) < 0 && errno != EEXIST) {
 		MGT_Complain(C_ERR, "Cannot create working directory '%s': %s",
-		    dname, strerror(errno));
+		    dname, vstrerror(errno));
 		return (1);
 	}
 	AZ(chown(dname, -1, vju_gid));
diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index efca546cd..d3fe23fa1 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -32,7 +32,6 @@
 #include "config.h"
 
 #include <ctype.h>
-#include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
 #include <stdio.h>
@@ -226,7 +225,7 @@ make_secret(const char *dirname)
 	fdo = open(fn, O_RDWR|O_CREAT|O_TRUNC, 0640);
 	if (fdo < 0)
 		ARGV_ERR("Cannot create secret-file in %s (%s)\n",
-		    dirname, strerror(errno));
+		    dirname, vstrerror(errno));
 
 	for (i = 0; i < 256; i++) {
 		AZ(VRND_RandomCrypto(&b, 1));
@@ -319,7 +318,7 @@ mgt_eric(void)
 
 	switch (fork()) {
 	case -1:
-		fprintf(stderr, "Fork() failed: %s\n", strerror(errno));
+		fprintf(stderr, "Fork() failed: %s\n", vstrerror(errno));
 		exit(-1);
 	case 0:
 		closefd(&eric_pipes[0]);
@@ -419,7 +418,7 @@ mgt_f_read(const char *fn)
 	VFIL_setpath(&vcl_path, mgt_vcl_path);
 	if (VFIL_searchpath(vcl_path, NULL, &f, fn, &fnp) || f == NULL) {
 		ARGV_ERR("Cannot read -f file '%s' (%s)\n",
-		    fnp != NULL ? fnp : fn, strerror(errno));
+		    fnp != NULL ? fnp : fn, vstrerror(errno));
 	}
 	free(fa->farg);
 	fa->farg = fnp;
@@ -626,7 +625,7 @@ main(int argc, char * const *argv)
 			I_fd = open(optarg, O_RDONLY);
 			if (I_fd < 0)
 				ARGV_ERR("\tCant open %s: %s\n",
-				    optarg, strerror(errno));
+				    optarg, vstrerror(errno));
 			VJ_master(JAIL_MASTER_LOW);
 			break;
 		case 'l':
@@ -732,13 +731,13 @@ main(int argc, char * const *argv)
 		o = open(S_arg, O_RDONLY, 0);
 		if (o < 0)
 			ARGV_ERR("Cannot open -S file (%s): %s\n",
-			    S_arg, strerror(errno));
+			    S_arg, vstrerror(errno));
 		closefd(&o);
 		VJ_master(JAIL_MASTER_LOW);
 	}
 
 	if (VIN_n_Arg(n_arg, &dirname) != 0)
-		ARGV_ERR("Invalid instance (-n) name: %s\n", strerror(errno));
+		ARGV_ERR("Invalid instance (-n) name: %s\n", vstrerror(errno));
 
 	if (i_arg == NULL || *i_arg == '\0')
 		i_arg = mgt_HostName();
@@ -750,12 +749,12 @@ main(int argc, char * const *argv)
 
 	if (VJ_make_workdir(dirname))
 		ARGV_ERR("Cannot create working directory (%s): %s\n",
-		    dirname, strerror(errno));
+		    dirname, vstrerror(errno));
 
 	if (VJ_make_subdir("vmod_cache", "VMOD cache", NULL)) {
 		ARGV_ERR(
 		    "Cannot create vmod directory (%s/vmod_cache): %s\n",
-		    dirname, strerror(errno));
+		    dirname, vstrerror(errno));
 	}
 
 	vsb = VSB_new_auto();
@@ -769,7 +768,7 @@ main(int argc, char * const *argv)
 		    (intmax_t)pid);
 	if (pfh1 == NULL)
 		ARGV_ERR("Could not open pid-file (%s): %s\n",
-		    VSB_data(vsb), strerror(errno));
+		    VSB_data(vsb), vstrerror(errno));
 	VSB_destroy(&vsb);
 	if (P_arg) {
 		pfh2 = VPF_Open(P_arg, 0644, &pid);
@@ -778,7 +777,7 @@ main(int argc, char * const *argv)
 			    (intmax_t)pid);
 		if (pfh2 == NULL)
 			ARGV_ERR("Could not open pid-file (%s): %s\n",
-			    P_arg, strerror(errno));
+			    P_arg, vstrerror(errno));
 	}
 	VJ_master(JAIL_MASTER_LOW);
 
diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c
index ddfa6504a..90e966f0e 100644
--- a/bin/varnishd/mgt/mgt_shmem.c
+++ b/bin/varnishd/mgt/mgt_shmem.c
@@ -32,7 +32,6 @@
 
 #include <sys/stat.h>
 
-#include <errno.h>
 #include <fcntl.h>
 #include <stdarg.h>
 #include <stdio.h>
diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c
index 2b476307b..dabf750a3 100644
--- a/bin/varnishd/mgt/mgt_vcc.c
+++ b/bin/varnishd/mgt/mgt_vcc.c
@@ -31,7 +31,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -212,13 +211,13 @@ mgt_vcc_touchfile(const char *fn, struct vsb *sb)
 
 	i = open(fn, O_WRONLY|O_CREAT|O_TRUNC, 0640);
 	if (i < 0) {
-		VSB_printf(sb, "Failed to create %s: %s", fn, strerror(errno));
+		VSB_printf(sb, "Failed to create %s: %s", fn, vstrerror(errno));
 		return (2);
 	}
 	if (fchown(i, mgt_param.uid, mgt_param.gid) != 0)
 		if (geteuid() == 0)
 			VSB_printf(sb, "Failed to change owner on %s: %s\n",
-			    fn, strerror(errno));
+			    fn, vstrerror(errno));
 	closefd(&i);
 	return (0);
 }
diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c
index 0edc68168..f1ce50f5d 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -31,7 +31,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -319,13 +318,13 @@ mgt_vcl_cache_vmod(const char *nm, const char *fm, const char *to)
 		return (0);
 	if (fo < 0) {
 		fprintf(stderr, "Creating copy of vmod %s: %s\n",
-		    nm, strerror(errno));
+		    nm, vstrerror(errno));
 		return (1);
 	}
 	fi = open(fm, O_RDONLY);
 	if (fi < 0) {
 		fprintf(stderr, "Opening vmod %s from %s: %s\n",
-		    nm, fm, strerror(errno));
+		    nm, fm, vstrerror(errno));
 		AZ(unlink(to));
 		closefd(&fo);
 		return (1);
@@ -336,7 +335,7 @@ mgt_vcl_cache_vmod(const char *nm, const char *fm, const char *to)
 			break;
 		if (sz < 0 || sz != write(fo, buf, sz)) {
 			fprintf(stderr, "Copying vmod %s: %s\n",
-			    nm, strerror(errno));
+			    nm, vstrerror(errno));
 			AZ(unlink(to));
 			ret = 1;
 			break;
diff --git a/bin/varnishd/storage/mgt_storage_persistent.c b/bin/varnishd/storage/mgt_storage_persistent.c
index b15be3f5c..e2fbf1c0f 100644
--- a/bin/varnishd/storage/mgt_storage_persistent.c
+++ b/bin/varnishd/storage/mgt_storage_persistent.c
@@ -40,7 +40,6 @@
 
 #include <sys/mman.h>
 
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -205,7 +204,7 @@ smp_mgt_init(struct stevedore *parent, int ac, char * const *av)
 
 	if (sc->base == MAP_FAILED)
 		ARGV_ERR("(-spersistent) failed to mmap (%s)\n",
-		    strerror(errno));
+		    vstrerror(errno));
 	if (target != NULL && sc->base != target)
 		fprintf(stderr, "WARNING: Persistent silo lost to ASLR %s\n",
 		    sc->filename);
diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c
index 80e8fd8eb..926c6b5a9 100644
--- a/bin/varnishd/storage/stevedore_utils.c
+++ b/bin/varnishd/storage/stevedore_utils.c
@@ -33,7 +33,6 @@
 
 #include <sys/stat.h>
 
-#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -102,7 +101,7 @@ STV_GetFile(const char *fn, int *fdp, const char **fnp, const char *ctx)
 		fd = mkstemp(buf);
 		if (fd < 0)
 			ARGV_ERR("(%s) \"%s\" mkstemp(%s) failed (%s)\n",
-			    ctx, fn, buf, strerror(errno));
+			    ctx, fn, buf, vstrerror(errno));
 		AZ(unlink(buf));
 		*fnp = strdup(buf);
 		AN(*fnp);
@@ -111,7 +110,7 @@ STV_GetFile(const char *fn, int *fdp, const char **fnp, const char *ctx)
 		fd = open(fn, O_RDWR | O_LARGEFILE);
 		if (fd < 0)
 			ARGV_ERR("(%s) \"%s\" could not open (%s)\n",
-			    ctx, fn, strerror(errno));
+			    ctx, fn, vstrerror(errno));
 		*fnp = fn;
 		retval = 0;
 	} else
diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c
index c2cb479ff..78588ccab 100644
--- a/bin/varnishd/storage/storage_file.c
+++ b/bin/varnishd/storage/storage_file.c
@@ -36,7 +36,6 @@
 
 #include <sys/mman.h>
 
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -162,7 +161,7 @@ smf_init(struct stevedore *parent, int ac, char * const *av)
 	MCH_Fd_Inherit(sc->fd, "storage_file");
 	sc->filesize = STV_FileSize(sc->fd, size, &sc->pagesize, "-sfile");
 	if (VFIL_allocate(sc->fd, (off_t)sc->filesize, 0))
-		ARGV_ERR("(-sfile) allocation error: %s\n", strerror(errno));
+		ARGV_ERR("(-sfile) allocation error: %s\n", vstrerror(errno));
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c
index d0a4c690d..f7dcc7c3f 100644
--- a/bin/varnishd/waiter/cache_waiter_epoll.c
+++ b/bin/varnishd/waiter/cache_waiter_epoll.c
@@ -39,7 +39,6 @@
 
 #include <sys/epoll.h>
 
-#include <errno.h>
 
 #include "cache/cache_varnishd.h"
 
diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c
index 4846488c5..5d34a5539 100644
--- a/bin/varnishd/waiter/cache_waiter_ports.c
+++ b/bin/varnishd/waiter/cache_waiter_ports.c
@@ -68,7 +68,6 @@
 
 #include <sys/time.h>
 
-#include <errno.h>
 #include <port.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c
index 21ca64666..626a80714 100644
--- a/bin/varnishhist/varnishhist.c
+++ b/bin/varnishhist/varnishhist.c
@@ -33,7 +33,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <limits.h>
 #include <math.h>
 #include <pthread.h>
diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c
index e3e2e4576..8abab3037 100644
--- a/bin/varnishlog/varnishlog.c
+++ b/bin/varnishlog/varnishlog.c
@@ -37,7 +37,6 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
-#include <errno.h>
 #include <stdint.h>
 
 #define VOPT_DEFINITION
diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c
index 6c859358e..f3ed20a78 100644
--- a/bin/varnishncsa/varnishncsa.c
+++ b/bin/varnishncsa/varnishncsa.c
@@ -43,7 +43,6 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
-#include <errno.h>
 #include <signal.h>
 #include <stdarg.h>
 #include <inttypes.h>
diff --git a/bin/varnishtest/vtc_barrier.c b/bin/varnishtest/vtc_barrier.c
index 7f2f0c1ce..7a7ac31f5 100644
--- a/bin/varnishtest/vtc_barrier.c
+++ b/bin/varnishtest/vtc_barrier.c
@@ -28,7 +28,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <poll.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/bin/varnishtest/vtc_client.c b/bin/varnishtest/vtc_client.c
index 5c714de0b..6966e462b 100644
--- a/bin/varnishtest/vtc_client.c
+++ b/bin/varnishtest/vtc_client.c
@@ -31,7 +31,6 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/bin/varnishtest/vtc_haproxy.c b/bin/varnishtest/vtc_haproxy.c
index 157d0e67c..9d12ed671 100644
--- a/bin/varnishtest/vtc_haproxy.c
+++ b/bin/varnishtest/vtc_haproxy.c
@@ -28,7 +28,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c
index 03aa7f7e5..e01ebc181 100644
--- a/bin/varnishtest/vtc_http.c
+++ b/bin/varnishtest/vtc_http.c
@@ -30,7 +30,6 @@
 
 #include <sys/socket.h>
 
-#include <errno.h>
 #include <math.h>
 #include <poll.h>
 #include <stdio.h>
diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c
index ed72ea37a..e942bab17 100644
--- a/bin/varnishtest/vtc_http2.c
+++ b/bin/varnishtest/vtc_http2.c
@@ -31,7 +31,6 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#include <errno.h>
 #include <math.h>
 #include <poll.h>
 #include <stdio.h>
diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c
index 1e6e321e8..60f0576b8 100644
--- a/bin/varnishtest/vtc_log.c
+++ b/bin/varnishtest/vtc_log.c
@@ -28,7 +28,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c
index 01ae08ba7..4b7fe2a4a 100644
--- a/bin/varnishtest/vtc_main.c
+++ b/bin/varnishtest/vtc_main.c
@@ -33,7 +33,6 @@
 #include <sys/wait.h>
 
 #include <ctype.h>
-#include <errno.h>
 #include <poll.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/bin/varnishtest/vtc_misc.c b/bin/varnishtest/vtc_misc.c
index 9fac1360a..e496de120 100644
--- a/bin/varnishtest/vtc_misc.c
+++ b/bin/varnishtest/vtc_misc.c
@@ -30,7 +30,6 @@
 
 #include <sys/wait.h>
 
-#include <errno.h>
 #include <grp.h>
 #include <math.h>
 #include <pwd.h>
diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c
index c6a5db295..2b1534be1 100644
--- a/bin/varnishtest/vtc_process.c
+++ b/bin/varnishtest/vtc_process.c
@@ -34,7 +34,6 @@
 #include <sys/ioctl.h>		// Linux: struct winsize
 
 #include <ctype.h>
-#include <errno.h>
 #include <fcntl.h>
 #include <inttypes.h>
 #include <poll.h>
diff --git a/bin/varnishtest/vtc_server.c b/bin/varnishtest/vtc_server.c
index d156185d9..1a7c06f87 100644
--- a/bin/varnishtest/vtc_server.c
+++ b/bin/varnishtest/vtc_server.c
@@ -32,7 +32,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/bin/varnishtest/vtc_subr.c b/bin/varnishtest/vtc_subr.c
index b3584a964..0e5922978 100644
--- a/bin/varnishtest/vtc_subr.c
+++ b/bin/varnishtest/vtc_subr.c
@@ -29,7 +29,6 @@
 #include "config.h"
 
 #include <sys/types.h>
-#include <errno.h>
 #include <math.h>
 #include <poll.h>
 #include <string.h>
diff --git a/bin/varnishtest/vtc_syslog.c b/bin/varnishtest/vtc_syslog.c
index f91014c9a..6318b6e39 100644
--- a/bin/varnishtest/vtc_syslog.c
+++ b/bin/varnishtest/vtc_syslog.c
@@ -31,7 +31,6 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index 0c7b3f5a3..4aa4680a5 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -31,7 +31,6 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#include <errno.h>
 #include <fcntl.h>
 #include <fnmatch.h>
 #include <inttypes.h>
diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c
index 2d72eadfe..f91e3cd01 100644
--- a/bin/varnishtop/varnishtop.c
+++ b/bin/varnishtop/varnishtop.c
@@ -34,7 +34,6 @@
 #include "config.h"
 
 #include <ctype.h>
-#include <errno.h>
 #include <pthread.h>
 #include <signal.h>
 #include <stdarg.h>
diff --git a/include/Makefile.am b/include/Makefile.am
index 98050fd78..802231dce 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -60,6 +60,7 @@ nobase_pkginclude_HEADERS += \
 	vbm.h \
 	vcl.h \
 	vcs.h \
+	verrno.h \
 	vmod_abi.h \
 	vqueue.h \
 	vre.h \
diff --git a/include/vas.h b/include/vas.h
index 11c00692d..841bd309a 100644
--- a/include/vas.h
+++ b/include/vas.h
@@ -38,6 +38,8 @@
 #ifndef VAS_H_INCLUDED
 #define VAS_H_INCLUDED
 
+#include "verrno.h"
+
 enum vas_e {
 	VAS_WRONG,
 	VAS_MISSING,
diff --git a/include/verrno.h b/include/verrno.h
new file mode 100644
index 000000000..f2ab427ed
--- /dev/null
+++ b/include/verrno.h
@@ -0,0 +1,12 @@
+/*-
+ * Written by Nils Goroll based upon a draft by Poul-Henning Kamp
+ *
+ * This file is in the public domain.
+ *
+ * trivial strerror() wrapper never returning NULL
+ */
+
+#include <errno.h>
+#include <string.h>
+
+const char * vstrerror(int e);
diff --git a/lib/libvarnish/Makefile.am b/lib/libvarnish/Makefile.am
index 2f4d3eb95..271b13c43 100644
--- a/lib/libvarnish/Makefile.am
+++ b/lib/libvarnish/Makefile.am
@@ -20,6 +20,7 @@ libvarnish_a_SOURCES = \
 	vcli_proto.c \
 	vcli_serve.c \
 	vct.c \
+	verrno.c \
 	version.c \
 	vev.c \
 	vfil.c \
diff --git a/lib/libvarnish/vas.c b/lib/libvarnish/vas.c
index 8380df999..3a9193268 100644
--- a/lib/libvarnish/vas.c
+++ b/lib/libvarnish/vas.c
@@ -31,7 +31,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/lib/libvarnish/vcli_proto.c b/lib/libvarnish/vcli_proto.c
index 789c08d93..d914f0879 100644
--- a/lib/libvarnish/vcli_proto.c
+++ b/lib/libvarnish/vcli_proto.c
@@ -31,7 +31,6 @@
 #include <sys/types.h>
 #include <sys/uio.h>
 
-#include <errno.h>
 #include <poll.h>
 #include <stdint.h>
 #include <stdio.h>
diff --git a/lib/libvarnish/vcli_serve.c b/lib/libvarnish/vcli_serve.c
index fc8578c50..e5cf0c411 100644
--- a/lib/libvarnish/vcli_serve.c
+++ b/lib/libvarnish/vcli_serve.c
@@ -33,7 +33,6 @@
 
 #include <time.h>
 #include <ctype.h>
-#include <errno.h>
 #include <poll.h>
 #include <stdarg.h>
 #include <stdint.h>
diff --git a/lib/libvarnish/verrno.c b/lib/libvarnish/verrno.c
new file mode 100644
index 000000000..2e377f7bd
--- /dev/null
+++ b/lib/libvarnish/verrno.c
@@ -0,0 +1,25 @@
+/*-
+ * Written by Nils Goroll based upon a draft by Poul-Henning Kamp
+ *
+ * This file is in the public domain.
+ *
+ * trivial strerror() wrapper never returning NULL
+ */
+
+#include "config.h"
+
+#include "verrno.h"
+
+const char *
+vstrerror(int e)
+{
+	const char *p;
+	int oerrno = errno;
+
+	p = strerror(e);
+	if (p != NULL)
+		return (p);
+
+	errno = oerrno;
+	return ("strerror(3) returned NULL");
+}
diff --git a/lib/libvarnish/vev.c b/lib/libvarnish/vev.c
index 0254a9cf7..6e4e48c7d 100644
--- a/lib/libvarnish/vev.c
+++ b/lib/libvarnish/vev.c
@@ -30,7 +30,6 @@
 #include "config.h"
 
 #include <time.h>
-#include <errno.h>
 #include <poll.h>
 #include <pthread.h>
 #include <signal.h>
diff --git a/lib/libvarnish/vfil.c b/lib/libvarnish/vfil.c
index 345096a7c..4dfc30faf 100644
--- a/lib/libvarnish/vfil.c
+++ b/lib/libvarnish/vfil.c
@@ -32,7 +32,6 @@
 #include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <errno.h>
 #include <fcntl.h>
 #include <limits.h>
 #include <stdio.h>
diff --git a/lib/libvarnish/vfl.c b/lib/libvarnish/vfl.c
index 9af496a91..fa7804569 100644
--- a/lib/libvarnish/vfl.c
+++ b/lib/libvarnish/vfl.c
@@ -32,13 +32,13 @@
 #include <sys/file.h>
 #include <sys/stat.h>
 
-#include <errno.h>
 #include <fcntl.h>
 #include <stdarg.h>
 #include <string.h>
 #include <unistd.h>
 
 #include "vfl.h"
+#include "verrno.h"
 
 /*
  * Reliably open and lock a file.
diff --git a/lib/libvarnish/vin.c b/lib/libvarnish/vin.c
index 6dac9d211..6c098afb7 100644
--- a/lib/libvarnish/vin.c
+++ b/lib/libvarnish/vin.c
@@ -30,7 +30,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <limits.h>
 #include <stdint.h>
 #include <stdio.h>
diff --git a/lib/libvarnish/vjsn.c b/lib/libvarnish/vjsn.c
index 4ba0cd4da..61280496a 100644
--- a/lib/libvarnish/vjsn.c
+++ b/lib/libvarnish/vjsn.c
@@ -28,7 +28,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <string.h>
diff --git a/lib/libvarnish/vpf.c b/lib/libvarnish/vpf.c
index cf326fb02..0c1bb1f2d 100644
--- a/lib/libvarnish/vpf.c
+++ b/lib/libvarnish/vpf.c
@@ -32,7 +32,6 @@
 #include <sys/file.h>
 #include <sys/stat.h>
 
-#include <errno.h>
 #include <fcntl.h>
 #include <stdint.h>
 #include <stdio.h>
diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c
index e1e6d1445..0e92b1771 100644
--- a/lib/libvarnish/vsb.c
+++ b/lib/libvarnish/vsb.c
@@ -30,7 +30,6 @@ __FBSDID("$FreeBSD: head/sys/kern/subr_vsb.c 222004 2011-05-17 06:36:32Z phk $")
 #include "config.h"
 
 #include <ctype.h>
-#include <errno.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/lib/libvarnish/vsub.c b/lib/libvarnish/vsub.c
index cafbe4086..06457992c 100644
--- a/lib/libvarnish/vsub.c
+++ b/lib/libvarnish/vsub.c
@@ -33,7 +33,6 @@
 
 #include <sys/wait.h>
 
-#include <errno.h>
 #include <stdint.h>
 #include <stdlib.h>		// Solaris closefrom(3c)
 #include <string.h>
diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c
index 93c2fce4a..3294bbf08 100644
--- a/lib/libvarnish/vtcp.c
+++ b/lib/libvarnish/vtcp.c
@@ -39,7 +39,6 @@
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 
-#include <errno.h>
 #include <math.h>
 #include <netdb.h>
 #include <poll.h>
diff --git a/lib/libvarnish/vus.c b/lib/libvarnish/vus.c
index f233c5f8f..ba8a3d507 100644
--- a/lib/libvarnish/vus.c
+++ b/lib/libvarnish/vus.c
@@ -30,7 +30,6 @@
 #include <sys/un.h>
 
 #include <unistd.h>
-#include <errno.h>
 #include <string.h>
 #include <poll.h>
 #include <stdio.h>
diff --git a/lib/libvarnishapi/daemon.c b/lib/libvarnishapi/daemon.c
index bd723517f..20d9ebc2c 100644
--- a/lib/libvarnishapi/daemon.c
+++ b/lib/libvarnishapi/daemon.c
@@ -32,7 +32,6 @@
 //lint -e{766}
 #include "config.h"
 
-#include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
 #include <unistd.h>
diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c
index 970c1750e..1818767a2 100644
--- a/lib/libvarnishapi/vsl.c
+++ b/lib/libvarnishapi/vsl.c
@@ -30,7 +30,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <stdarg.h>
 #include <stdint.h>
 #include <stdio.h>
diff --git a/lib/libvarnishapi/vsl_cursor.c b/lib/libvarnishapi/vsl_cursor.c
index 8559c071a..652751c52 100644
--- a/lib/libvarnishapi/vsl_cursor.c
+++ b/lib/libvarnishapi/vsl_cursor.c
@@ -31,7 +31,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <fcntl.h>
 #include <stdint.h>
 #include <stdio.h>
diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c
index 36d737775..7380bbae3 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -33,7 +33,6 @@
 #include <sys/mman.h>
 #include <sys/stat.h>
 
-#include <errno.h>
 #include <fcntl.h>
 #include <float.h>
 #include <math.h>
diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c
index 9c02bf407..9c767bfe7 100644
--- a/lib/libvarnishapi/vut.c
+++ b/lib/libvarnishapi/vut.c
@@ -37,7 +37,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <errno.h>
 #include <string.h>
 #include <signal.h>
 #include <sys/stat.h> /* for MUSL */
diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c
index bcfaadcab..adfee9579 100644
--- a/lib/libvcc/vcc_compile.c
+++ b/lib/libvcc/vcc_compile.c
@@ -52,7 +52,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/lib/libvcc/vcc_utils.c b/lib/libvcc/vcc_utils.c
index b28f1628f..e92be266f 100644
--- a/lib/libvcc/vcc_utils.c
+++ b/lib/libvcc/vcc_utils.c
@@ -36,7 +36,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <errno.h>
 
 #include "vcc_compile.h"
 
diff --git a/lib/libvmod_blob/base64.c b/lib/libvmod_blob/base64.c
index 3bea94871..62ad71e39 100644
--- a/lib/libvmod_blob/base64.c
+++ b/lib/libvmod_blob/base64.c
@@ -27,7 +27,6 @@
  */
 
 #include "config.h"
-#include <errno.h>
 
 #include "vdef.h"
 #include "vrt.h"
diff --git a/lib/libvmod_blob/hex.c b/lib/libvmod_blob/hex.c
index dfdbb3e9e..2306a2fec 100644
--- a/lib/libvmod_blob/hex.c
+++ b/lib/libvmod_blob/hex.c
@@ -28,7 +28,6 @@
 
 #include "config.h"
 #include <ctype.h>
-#include <errno.h>
 
 #include "hex.h"
 
diff --git a/lib/libvmod_blob/id.c b/lib/libvmod_blob/id.c
index 1164e983d..3fc8d5280 100644
--- a/lib/libvmod_blob/id.c
+++ b/lib/libvmod_blob/id.c
@@ -28,7 +28,6 @@
 
 #include "config.h"
 #include <string.h>
-#include <errno.h>
 
 #include "vdef.h"
 #include "vrt.h"
diff --git a/lib/libvmod_blob/url.c b/lib/libvmod_blob/url.c
index acb55a6bb..1713bb5ab 100644
--- a/lib/libvmod_blob/url.c
+++ b/lib/libvmod_blob/url.c
@@ -27,7 +27,6 @@
  */
 
 #include "config.h"
-#include <errno.h>
 
 #include "hex.h"
 
diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c
index 013533ae9..1b675abb2 100644
--- a/lib/libvmod_blob/vmod_blob.c
+++ b/lib/libvmod_blob/vmod_blob.c
@@ -27,7 +27,6 @@
  */
 
 #include "config.h"
-#include <errno.h>
 #include <string.h>
 
 #include "cache/cache.h"
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 61029ad94..8851ae6e4 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -28,7 +28,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
diff --git a/lib/libvmod_debug/vmod_debug_dyn.c b/lib/libvmod_debug/vmod_debug_dyn.c
index cd0b7b6a3..c7026b4ea 100644
--- a/lib/libvmod_debug/vmod_debug_dyn.c
+++ b/lib/libvmod_debug/vmod_debug_dyn.c
@@ -35,7 +35,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <errno.h>
 
 #include "cache/cache.h"
 
diff --git a/lib/libvmod_unix/cred_compat.h b/lib/libvmod_unix/cred_compat.h
index cd4fd7437..fe3a5b9ff 100644
--- a/lib/libvmod_unix/cred_compat.h
+++ b/lib/libvmod_unix/cred_compat.h
@@ -27,7 +27,6 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <errno.h>
 
 #if defined(HAVE_GETPEEREID)
 #include <unistd.h>
diff --git a/lib/libvmod_vtc/vmod_vtc.c b/lib/libvmod_vtc/vmod_vtc.c
index 6b6501adf..c2d4f383c 100644
--- a/lib/libvmod_vtc/vmod_vtc.c
+++ b/lib/libvmod_vtc/vmod_vtc.c
@@ -29,7 +29,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>


More information about the varnish-commit mailing list