[4.0] 25ad44e Strictly speaking

Lasse Karstensen lkarsten at varnish-software.com
Mon Sep 22 16:38:23 CEST 2014


commit 25ad44eabf0b857eb00383e08a6bbe5d83969405
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Aug 12 08:27:54 2014 +0000

    Strictly speaking
    
    	int
    	foo()
    	{
    		int bar;
    
    		(void)bar;
    		[...]
    	}
    
    Isn't valid C because bar has an undefined value when you cast its
    value away.  Yes, many thanks to ISO-C for that gem.
    
    Memset the variables to zero instead.

diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index af86b2b..7afcef6 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -131,8 +131,8 @@ vca_tcp_opt_init(void)
 	int chg = 0;
 	int x;
 
-	(void)tv;
-	(void)x;
+	memset(&tv, 0, sizeof tv);
+	memset(&x, 0, sizeof x);
 
 	for (n = 0; n < n_tcp_opts; n++) {
 		to = &tcp_opts[n];



More information about the varnish-commit mailing list