[master] ec0edf5e6 Revert "do not pass a NULL pointer from strerror() to vsnprintf via VSL"

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


commit ec0edf5e679ea5557e633fe2d737bd46e1683543
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Thu Nov 1 15:10:22 2018 +0100

    Revert "do not pass a NULL pointer from strerror() to vsnprintf via VSL"
    
    This reverts commit ee33662a162cbc4fcc7fb8a93d143f85b7786eae.

diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 13223c29d..8282ed814 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -666,12 +666,8 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
 
 	pan_backtrace(pan_vsb);
 
-	if (err) {
-		q = strerror(err);
-		if (q == NULL)
-			q = "(strerror failed)";
-		VSB_printf(pan_vsb, "errno = %d (%s)\n", err, q);
-	}
+	if (err)
+		VSB_printf(pan_vsb, "errno = %d (%s)\n", err, strerror(err));
 
 	q = THR_GetName();
 	if (q != NULL)
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index a4d9a33ad..4d546ffd3 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -437,8 +437,6 @@ pool_breed(struct pool *qp)
 	pthread_t tp;
 	pthread_attr_t tp_attr;
 	struct pool_info *pi;
-	const char *strerr;
-	int err;
 
 	AZ(pthread_attr_init(&tp_attr));
 	AZ(pthread_attr_setdetachstate(&tp_attr, PTHREAD_CREATE_DETACHED));
@@ -454,12 +452,8 @@ pool_breed(struct pool *qp)
 	pi->qp = qp;
 
 	if (pthread_create(&tp, &tp_attr, pool_thread, pi)) {
-		err = errno;
-		strerr = strerror(errno);
-		if (strerr == NULL)
-			strerr = "(strerror failed)";
 		VSL(SLT_Debug, 0, "Create worker thread failed %d %s",
-		    err, strerr);
+		    errno, strerror(errno));
 		Lck_Lock(&pool_mtx);
 		VSC_C_main->threads_failed++;
 		Lck_Unlock(&pool_mtx);


More information about the varnish-commit mailing list