[6.0] 9f72469f2 Make VCC not fail if you try to pass STRANDS to STRING_LIST.

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Wed Jul 3 14:40:10 UTC 2019


commit 9f72469f249d13aa968c2a928f97490ed3d40544
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Jan 4 10:15:59 2019 +0000

    Make VCC not fail if you try to pass STRANDS to STRING_LIST.
    
    Strenghen the case against STRING_LIST in the docs.
    
    See also: #2873
    
    Conflicts:
            lib/libvmod_debug/vmod.vcc

diff --git a/bin/varnishtest/tests/m00000.vtc b/bin/varnishtest/tests/m00000.vtc
index 355bb3c56..e7f1d4ad1 100644
--- a/bin/varnishtest/tests/m00000.vtc
+++ b/bin/varnishtest/tests/m00000.vtc
@@ -120,3 +120,10 @@ varnish v1 -errvcl {Expression has type STRING, expected REAL} {
 		set resp.http.who = std.random("foo", "bar");
 	}
 }
+
+varnish v1 -errvcl {Cannot convert type STRING(STRANDS) to STRING(STRING_LIST)} {
+	import debug;
+	sub vcl_deliver {
+		set resp.http.who = debug.return_strands(req.url + "bar");
+	}
+}
diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst
index 8978ca4f2..1897029ad 100644
--- a/doc/sphinx/reference/vmod.rst
+++ b/doc/sphinx/reference/vmod.rst
@@ -390,9 +390,8 @@ STEVEDORE
 STRING_LIST
 	C-type: ``const char *, ...``
 
-	`Notice: New vmod developments for 6.1 and higher should
-	consider STRANDS as a better alternative to STRING_LIST, which
-	will eventually be replaced entirely.`
+	`Notice: New vmod developments for 6.1 and later must
+	use STRANDS instead of STRING_LIST, which is going away.`
 
 	A multi-component text-string.  We try very hard to avoid
 	doing text-processing in Varnish, and this is one way we
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index 2b3602bcb..61dca8e19 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -1312,7 +1312,14 @@ vcc_expr0(struct vcc *tl, struct expr **e, vcc_type_t fmt)
 	else
 		vcc_expr_cor(tl, e, fmt);
 	ERRCHK(tl);
-	assert(!(*e)->fmt->stringform);
+
+	if ((*e)->fmt->stringform) {
+		VSB_printf(tl->sb, "Cannot convert type %s(%s) to %s(%s)\n",
+		    vcc_utype((*e)->fmt), (*e)->fmt->name,
+		    vcc_utype(fmt), fmt->name);
+		vcc_ErrWhere2(tl, t1, tl->t);
+		return;
+	}
 
 	if ((*e)->fmt != STRINGS && fmt->stringform)
 		vcc_expr_tostring(tl, e, STRINGS);
diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc
index 234be9e06..04d0088d9 100644
--- a/lib/libvmod_debug/vmod.vcc
+++ b/lib/libvmod_debug/vmod.vcc
@@ -217,6 +217,8 @@ $Method STRING .meth_opt(PRIV_CALL, PRIV_VCL, PRIV_TASK,
 
 Test object method with all the fancy stuff.
 
+$Function STRANDS return_strands(STRANDS strand)
+
 $Function VOID store_ip(PRIV_TASK, IP)
 
 Store an IP address to be later found by ``debug.get_ip()`` in the same
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index ebc26f38d..2ed000d64 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -548,3 +548,11 @@ xyzzy_get_ip(VRT_CTX, struct vmod_priv *priv)
 
 	return (ip);
 }
+
+VCL_STRANDS
+xyzzy_return_strands(VRT_CTX, VCL_STRANDS strand)
+{
+
+	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+	return (strand);
+}


More information about the varnish-commit mailing list