[master] 3ff762862 Make sure to use none backends in generated C code

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Fri Nov 15 16:18:05 UTC 2019


commit 3ff7628628b0c1fb846fd86576bd1c9048517251
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Fri Nov 15 17:04:40 2019 +0100

    Make sure to use none backends in generated C code
    
    Otherwise you might run into this:
    
        Message from VCC-compiler:
        Unused backend nil, defined:
        ('<vcl.inline>' Line 4 Pos 17)
                backend nil none;
        ----------------###------
    
        (That was just a warning)
        Message from C-compiler:
        vgc.c:1476:20: error: unused variable 'vgc_backend_nil' [-Werror,-Wunused-variable]
        static VCL_BACKEND vgc_backend_nil;
                           ^
        1 error generated.
        Running C-compiler failed, exited with 1
        VCL compilation failed
    
    This is done in both init and discard code to maintain the balance.

diff --git a/bin/varnishtest/tests/v00060.vtc b/bin/varnishtest/tests/v00060.vtc
index b1540dd5a..28bbcb89f 100644
--- a/bin/varnishtest/tests/v00060.vtc
+++ b/bin/varnishtest/tests/v00060.vtc
@@ -43,3 +43,9 @@ client c1 {
 	rxresp
 	expect resp.status == 503
 } -run
+
+varnish v1 -cliok "param.set vcc_err_unref off"
+varnish v1 -vcl {
+	backend bad { .host = "${bad_backend}"; }
+	backend nil none;
+}
diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c
index c8f5ee8cd..374eeec5c 100644
--- a/lib/libvcc/vcc_backend.c
+++ b/lib/libvcc/vcc_backend.c
@@ -330,6 +330,9 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname)
 		Fb(tl, 0, "\n\t%s = (NULL);\n", vgcname);
 		vcc_NextToken(tl);
 		SkipToken(tl, ';');
+		ifp = New_IniFin(tl);
+		VSB_printf(ifp->ini, "\t(void)%s;\n", vgcname);
+		VSB_printf(ifp->fin, "\t\t(void)%s;\n", vgcname);
 		return;
 	}
 


More information about the varnish-commit mailing list