[master] 5db1061f3 Change VRT_hashdata() to take STRANDS

Poul-Henning Kamp phk at FreeBSD.org
Thu Jun 20 20:27:11 UTC 2019


commit 5db1061f31443382f2c4c84a10827626b2cee41c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Jun 20 20:11:50 2019 +0000

    Change VRT_hashdata() to take STRANDS

diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index fee4b8567..812883fe9 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -555,23 +555,16 @@ VRT_fail(VRT_CTX, const char *fmt, ...)
  */
 
 VCL_VOID
-VRT_hashdata(VRT_CTX, const char *str, ...)
+VRT_hashdata(VRT_CTX, VCL_STRANDS s)
 {
-	va_list ap;
-	const char *p;
+	int i;
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
 	CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
 	AN(ctx->specific);
-	HSH_AddString(ctx->req, ctx->specific, str);
-	va_start(ap, str);
-	while (1) {
-		p = va_arg(ap, const char *);
-		if (p == vrt_magic_string_end)
-			break;
-		HSH_AddString(ctx->req, ctx->specific, p);
-	}
-	va_end(ap);
+	AN(s);
+	for (i = 0; i < s->n; i++)
+		HSH_AddString(ctx->req, ctx->specific, s->p[i]);
 	/*
 	 * Add a 'field-separator' to make it more difficult to
 	 * manipulate the hash.
diff --git a/include/vrt.h b/include/vrt.h
index 0f022a3b2..a5d6d00ff 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -52,6 +52,7 @@
  * binary/load-time compatible, increment MAJOR version
  *
  * unreleased (planned for 2019-09-15)
+ *	VRT_hashdata() now takes STRANDS argument
  *	VCL_BOOL VRT_Strands2Bool(VCL_STRANDS) added.
  *	VRT_BundleStrands() moved to vcc_interface.h
  *	VRT_VCL_{Busy|Unbusy} changed to VRT_VCL_{Prevent|Allow}_Cold
@@ -438,7 +439,7 @@ VCL_VOID VRT_hit_for_pass(VRT_CTX, VCL_DURATION);
 VCL_VOID VRT_SetHdr(VRT_CTX, VCL_HEADER, const char *, ...);
 VCL_VOID VRT_handling(VRT_CTX, unsigned hand);
 VCL_VOID VRT_fail(VRT_CTX, const char *fmt, ...) v_printflike_(2,3);
-VCL_VOID VRT_hashdata(VRT_CTX, const char *str, ...);
+VCL_VOID VRT_hashdata(VRT_CTX, VCL_STRANDS);
 
 /* Simple stuff */
 int VRT_strcmp(const char *s1, const char *s2);
diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c
index 9ce0e6312..83c897df4 100644
--- a/lib/libvcc/vcc_action.c
+++ b/lib/libvcc/vcc_action.c
@@ -193,7 +193,7 @@ vcc_act_hash_data(struct vcc *tl, struct token *t, struct symbol *sym)
 	SkipToken(tl, '(');
 
 	Fb(tl, 1, "VRT_hashdata(ctx,\n  ");
-	vcc_Expr(tl, STRING_LIST);
+	vcc_Expr(tl, STRANDS);
 	ERRCHK(tl);
 	Fb(tl, 1, ");\n");
 	SkipToken(tl, ')');


More information about the varnish-commit mailing list