[master] 28902ab94 Convert VRT_l_* to "const char *, VCL_STRANDS" format.

Poul-Henning Kamp phk at FreeBSD.org
Fri Aug 20 13:52:05 UTC 2021


commit 28902ab948080069d588767d0db244669fa7ee1f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Aug 20 13:50:20 2021 +0000

    Convert VRT_l_* to "const char *, VCL_STRANDS" format.

diff --git a/bin/varnishd/cache/cache_vrt_filter.c b/bin/varnishd/cache/cache_vrt_filter.c
index 1baf344f5..cab61ea74 100644
--- a/bin/varnishd/cache/cache_vrt_filter.c
+++ b/bin/varnishd/cache/cache_vrt_filter.c
@@ -406,15 +406,13 @@ resp_Get_Filter_List(struct req *req)
 	}								\
 									\
 	VCL_VOID							\
-	VRT_l_##vcl##_filters(VRT_CTX, const char *str, ...)		\
+	VRT_l_##vcl##_filters(VRT_CTX, const char *str, VCL_STRANDS s)	\
 	{								\
-		va_list ap;						\
 		const char *b;						\
 									\
+		(void)str;						\
 		CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);			\
-		va_start(ap, str);					\
-		b = VRT_String(ctx->in->ws, NULL, str, ap);		\
-		va_end(ap);						\
+		b = VRT_StrandsWS(ctx->in->ws, str, s);			\
 		if (b == NULL)						\
 			WS_MarkOverflow(ctx->in->ws);			\
 		else							\
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 35ef4ee29..2b05aac01 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -50,14 +50,14 @@ static char vrt_hostname[255] = "";
  */
 
 static void
-vrt_do_string(VRT_CTX, struct http *hp, int fld,
-    const char *err, const char *p, va_list ap)
+vrt_do_strands(VRT_CTX, struct http *hp, int fld,
+    const char *err, const char *str, VCL_STRANDS s)
 {
 	const char *b;
 
 	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
 
-	b = VRT_String(hp->ws, NULL, p, ap);
+	b = VRT_StrandsWS(hp->ws, str, s);
 	if (b == NULL) {
 		VRT_fail(ctx, "Workspace overflow (%s)", err);
 		WS_MarkOverflow(hp->ws);
@@ -72,14 +72,11 @@ vrt_do_string(VRT_CTX, struct http *hp, int fld,
 
 #define VRT_HDR_L(obj, hdr, fld)					\
 VCL_VOID								\
-VRT_l_##obj##_##hdr(VRT_CTX, const char *p, ...)			\
+VRT_l_##obj##_##hdr(VRT_CTX, const char *str, VCL_STRANDS s)		\
 {									\
-	va_list ap;							\
 									\
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);				\
-	va_start(ap, p);						\
-	vrt_do_string(ctx, ctx->http_##obj, fld, #obj "." #hdr, p, ap);	\
-	va_end(ap);							\
+	vrt_do_strands(ctx, ctx->http_##obj, fld, #obj "." #hdr, str, s);	\
 }
 
 #define VRT_HDR_R(obj, hdr, fld)					\
@@ -316,16 +313,13 @@ VRT_r_client_identity(VRT_CTX)
 }
 
 VCL_VOID
-VRT_l_client_identity(VRT_CTX, const char *str, ...)
+VRT_l_client_identity(VRT_CTX, const char *str, VCL_STRANDS s)
 {
-	va_list ap;
 	const char *b;
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
 	CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
-	va_start(ap, str);
-	b = VRT_String(ctx->req->http->ws, NULL, str, ap);
-	va_end(ap);
+	b = VRT_StrandsWS(ctx->req->http->ws, str, s);
 	if (b == NULL) {
 		VSLb(ctx->vsl, SLT_LostHeader, "client.identity");
 		WS_MarkOverflow(ctx->req->http->ws);
@@ -441,24 +435,18 @@ VRT_r_beresp_storage_hint(VRT_CTX)
 }
 
 VCL_VOID
-VRT_l_beresp_storage_hint(VRT_CTX, const char *str, ...)
+VRT_l_beresp_storage_hint(VRT_CTX, const char *str, VCL_STRANDS s)
 {
 	const char *p;
-	va_list ap;
-	uintptr_t sn;
 	VCL_STEVEDORE stv;
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
 	CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
 
-	sn = WS_Snapshot(ctx->ws);
-	va_start(ap, str);
-	p = VRT_String(ctx->ws, NULL, str, ap);
-	va_end(ap);
+	p = VRT_StrandsWS(ctx->ws, str, s);
 
 	if (p == NULL) {
 		VSLb(ctx->vsl, SLT_LostHeader, "storage_hint");
-		WS_Reset(ctx->ws, sn);
 		WS_MarkOverflow(ctx->ws);
 		return;
 	}
@@ -466,8 +454,6 @@ VRT_l_beresp_storage_hint(VRT_CTX, const char *str, ...)
 	stv = VRT_stevedore(p);
 	if (stv != NULL)
 		ctx->bo->storage = stv;
-
-	WS_Reset(ctx->ws, sn);
 }
 
 /*--------------------------------------------------------------------*/
@@ -950,7 +936,8 @@ VRT_r_resp_do_esi(VRT_CTX)
 
 #define VRT_BODY_L(which)					\
 VCL_VOID							\
-VRT_l_##which##_body(VRT_CTX, enum lbody_e type, VCL_STRANDS s)	\
+VRT_l_##which##_body(VRT_CTX, enum lbody_e type,		\
+    const char *str, VCL_STRANDS s)				\
 {								\
 	int n;							\
 	struct vsb *vsb;					\
@@ -959,7 +946,9 @@ VRT_l_##which##_body(VRT_CTX, enum lbody_e type, VCL_STRANDS s)	\
 	assert(type == LBODY_SET || type == LBODY_ADD);		\
 	if (type == LBODY_SET)					\
 		VSB_clear(vsb);					\
-	for (n = 0; n < s->n; n++)				\
+	if (str != NULL)					\
+		VSB_cat(vsb, str);				\
+	for (n = 0; s != NULL && n < s->n; n++)			\
 		if (s->p[n] != NULL)				\
 			VSB_cat(vsb, s->p[n]);			\
 }
diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py
index 58b1f7858..f5fd13a26 100755
--- a/lib/libvcc/generate.py
+++ b/lib/libvcc/generate.py
@@ -217,10 +217,9 @@ class vardef(object):
             fo.write('\tsym->lname = "VRT_l_%s(ctx, ";\n' % cnam)
             s = "void VRT_l_%s(VRT_CTX, " % cnam
             if self.typ == "STRING":
-                s += ctyp.c + ", ...)"
+                s += ctyp.c + ", VCL_STRANDS)"
             elif self.typ == "BODY":
-                #s += "enum lbody_e, " + ctyp.c + ", VCL_STRANDS)"
-                s += "enum lbody_e, VCL_STRANDS)"
+                s += "enum lbody_e, " + ctyp.c + ", VCL_STRANDS)"
             else:
                 s += "VCL_" + self.typ + ")"
             varproto(s)
diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c
index fbd0cd004..7c7a57714 100644
--- a/lib/libvcc/vcc_action.c
+++ b/lib/libvcc/vcc_action.c
@@ -117,12 +117,12 @@ static const struct assign {
 	{ DURATION,	T_DIV,		REAL, "\v / " },
 	{ DURATION,	'=',		DURATION },
 	{ DURATION,	0,		DURATION },
-	{ STRING,	T_INCR,		STRING_LIST, "\v,\n" },
-	{ STRING,	'=',		STRING_LIST },
+	{ STRING,	T_INCR,		STRANDS, "\v,\n" },
+	{ STRING,	'=',		STRANDS, "0,\n" },
 	{ HEADER,	T_INCR,		STRANDS, "VRT_GetHdr(ctx, \v),\n" },
-	{ HEADER,	'=',		STRANDS, "NULL,\n" },
-	{ BODY,		'=',		STRANDS, "LBODY_SET,\n" },
-	{ BODY,		T_INCR,		STRANDS, "LBODY_ADD,\n" },
+	{ HEADER,	'=',		STRANDS, "0,\n" },
+	{ BODY,		'=',		STRANDS, "LBODY_SET, 0,\n" },
+	{ BODY,		T_INCR,		STRANDS, "LBODY_ADD, 0,\n" },
 	{ VOID,		'=',		VOID }
 };
 


More information about the varnish-commit mailing list