[master] f61dde46f vcc: Pass literal VCL_STRANDS arguments

Nils Goroll nils.goroll at uplex.de
Fri Nov 20 15:23:07 UTC 2020


commit f61dde46f4e3863543a21ebcbe64767d2ef5807b
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Tue Oct 27 23:42:08 2020 +0100

    vcc: Pass literal VCL_STRANDS arguments
    
    avoiding local variables and VPI_BundleStrands()
    
    Fixes #3392

diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index ceb6f3441..f5fa84ea3 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -222,27 +222,6 @@ VRT_AllocStrandsWS(struct ws *ws, int n)
 	return (s);
 }
 
-/*--------------------------------------------------------------------
- * Build STRANDS from what is essentially a STRING_LIST
- */
-
-VCL_STRANDS
-VPI_BundleStrands(int n, struct strands *s, char const **d, const char *f, ...)
-{
-	va_list ap;
-
-	assert(n > 0);
-	s->n = n;
-	s->p = d;
-	*d++ = f;
-	va_start(ap, f);
-	while(--n)
-		*d++ = va_arg(ap, const char *);
-	assert(va_arg(ap, const char *) == vrt_magic_string_end);
-	va_end(ap);
-	return (s);
-}
-
 /*--------------------------------------------------------------------
  * Compare two STRANDS
  */
diff --git a/include/vcc_interface.h b/include/vcc_interface.h
index 9d9f46d6d..c754af479 100644
--- a/include/vcc_interface.h
+++ b/include/vcc_interface.h
@@ -71,6 +71,3 @@ struct vpi_ii {
 	const void *			p;
 	const char * const		name;
 };
-
-VCL_STRANDS VPI_BundleStrands(int, struct strands *, char const **,
-    const char *f, ...);
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index 1447ec2b3..376e8f614 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -153,6 +153,8 @@ vcc_expr_edit(struct vcc *tl, vcc_type_t fmt, const char *p, struct expr *e1,
 	struct expr *e, *e3;
 	int nl = 1;
 
+	(void) tl;
+
 	AN(e1);
 	e = vcc_new_expr(fmt);
 	while (*p != '\0') {
@@ -184,16 +186,10 @@ vcc_expr_edit(struct vcc *tl, vcc_type_t fmt, const char *p, struct expr *e1,
 		case 't':
 			e3 = (*p == 'T' ? e1 : e2);
 			AN(e3);
-			VSB_printf(tl->curproc->prologue,
-			    "  struct strands strs_%u_a;\n"
-			    "  const char * strs_%u_s[%d];\n",
-			    tl->unique, tl->unique, e3->nstr);
 			VSB_printf(e->vsb,
-			    "VPI_BundleStrands(%d, &strs_%u_a, strs_%u_s,"
-			    "\v+\n%s,\nvrt_magic_string_end\v-\n)",
-			    e3->nstr, tl->unique, tl->unique,
-			VSB_data(e3->vsb));
-			tl->unique++;
+			    "&(struct strands){.n = %d, .p = "
+			    "(const char *[%d]){\n%s\n}}",
+			    e3->nstr, e3->nstr, VSB_data(e3->vsb));
 			break;
 		case '1':
 			VSB_cat(e->vsb, VSB_data(e1->vsb));


More information about the varnish-commit mailing list