[master] 24455b707 Merge from VTEST:

Poul-Henning Kamp phk at FreeBSD.org
Mon Dec 2 12:00:08 UTC 2019


commit 24455b70728605a380c46454ef5dfdc598fc599e
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Dec 2 11:53:35 2019 +0000

    Merge from VTEST:
    
        Avoid VSB_printf for static strings
    
        Done with the following semantic patch for Coccinelle:
    
            @@
            expression vsb, fmt;
            @@
    
            - VSB_printf(vsb, fmt);
            + VSB_cat(vsb, fmt);
    
        This patch is available in the Varnish source tree.

diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c
index 1bdd5699c..be67a5d9c 100644
--- a/bin/varnishtest/vtc_log.c
+++ b/bin/varnishtest/vtc_log.c
@@ -257,7 +257,7 @@ vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx,
 	else {
 		for (l = 0; l < len; l++, ss++) {
 			if (l > 512) {
-				VSB_printf(vl->vsb, "...");
+				VSB_cat(vl->vsb, "...");
 				break;
 			}
 			if (nl) {
@@ -266,13 +266,13 @@ vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx,
 			}
 			VSB_printf(vl->vsb, " %02x", *ss);
 			if ((l & 0xf) == 0xf) {
-				VSB_printf(vl->vsb, "\n");
+				VSB_cat(vl->vsb, "\n");
 				nl = 1;
 			}
 		}
 	}
 	if (!nl)
-		VSB_printf(vl->vsb, "\n");
+		VSB_cat(vl->vsb, "\n");
 	REL_VL(vl);
 	if (lvl == 0)
 		vtc_logfail();
diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c
index a2c346067..c61ab7c7d 100644
--- a/bin/varnishtest/vtc_main.c
+++ b/bin/varnishtest/vtc_main.c
@@ -507,7 +507,7 @@ i_mode(void)
 	/*
 	 * Build $PATH which can find all programs in the build tree
 	 */
-	VSB_printf(vsb, "PATH=");
+	VSB_cat(vsb, "PATH=");
 	sep = "";
 #define VTC_PROG(l)							\
 	do {								\
@@ -688,7 +688,7 @@ main(int argc, char * const *argv)
 	AN(cbvsb);
 	setbuf(stdout, NULL);
 	setbuf(stderr, NULL);
-	while ((ch = getopt(argc, argv, "b:CD:hij:kLln:p:qt:vW")) != -1) {
+	while ((ch = getopt(argc, argv, "b:CD:hij:kLln:p:qt:v")) != -1) {
 		switch (ch) {
 		case 'b':
 			if (VNUM_2bytes(optarg, &bufsiz, 0)) {
@@ -732,7 +732,7 @@ main(int argc, char * const *argv)
 			ntest = strtoul(optarg, NULL, 0);
 			break;
 		case 'p':
-			VSB_printf(params_vsb, " -p ");
+			VSB_cat(params_vsb, " -p ");
 			VSB_quote(params_vsb, optarg, -1, 0);
 			break;
 		case 'q':
diff --git a/bin/varnishtest/vtc_proxy.c b/bin/varnishtest/vtc_proxy.c
index 4477ab056..ffa322e85 100644
--- a/bin/varnishtest/vtc_proxy.c
+++ b/bin/varnishtest/vtc_proxy.c
@@ -100,9 +100,9 @@ vtc_send_proxy(int fd, int version, const struct suckaddr *sac,
 	if (version == 1) {
 		VSB_bcat(vsb, vpx1_sig, sizeof(vpx1_sig));
 		if (proto == PF_INET6)
-			VSB_printf(vsb, " TCP6 ");
+			VSB_cat(vsb, " TCP6 ");
 		else if (proto == PF_INET)
-			VSB_printf(vsb, " TCP4 ");
+			VSB_cat(vsb, " TCP4 ");
 		VTCP_name(sac, hc, sizeof(hc), pc, sizeof(pc));
 		VTCP_name(sas, hs, sizeof(hs), ps, sizeof(ps));
 		VSB_printf(vsb, "%s %s %s %s\r\n", hc, hs, pc, ps);
diff --git a/bin/varnishtest/vtc_server.c b/bin/varnishtest/vtc_server.c
index 9a1a0d68e..3ff49705e 100644
--- a/bin/varnishtest/vtc_server.c
+++ b/bin/varnishtest/vtc_server.c
@@ -67,7 +67,8 @@ struct server {
 
 static pthread_mutex_t		server_mtx;
 
-static VTAILQ_HEAD(, server)	servers = VTAILQ_HEAD_INITIALIZER(servers);
+static VTAILQ_HEAD(, server)	servers =
+    VTAILQ_HEAD_INITIALIZER(servers);
 
 /**********************************************************************
  * Allocate and initialize a server
diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index 24ffab467..483690cbb 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -407,7 +407,7 @@ varnish_launch(struct varnish *v)
 	vtc_log(v->vl, 2, "Launch");
 	vsb = VSB_new_auto();
 	AN(vsb);
-	VSB_printf(vsb, "cd ${pwd} &&");
+	VSB_cat(vsb, "cd ${pwd} &&");
 	VSB_printf(vsb, " exec varnishd %s -d -n %s",
 	    v->jail, v->workdir);
 	VSB_cat(vsb, VSB_data(params_vsb));
@@ -416,13 +416,13 @@ varnish_launch(struct varnish *v)
 		VSB_cat(vsb, " -p debug=+vmod_so_keep");
 		VSB_cat(vsb, " -p debug=+vsm_keep");
 	}
-	VSB_printf(vsb, " -l 2m");
-	VSB_printf(vsb, " -p auto_restart=off");
-	VSB_printf(vsb, " -p syslog_cli_traffic=off");
-	VSB_printf(vsb, " -p sigsegv_handler=on");
-	VSB_printf(vsb, " -p thread_pool_min=10");
-	VSB_printf(vsb, " -p debug=+vtc_mode");
-	VSB_printf(vsb, " -p vsl_mask=+Debug");
+	VSB_cat(vsb, " -l 2m");
+	VSB_cat(vsb, " -p auto_restart=off");
+	VSB_cat(vsb, " -p syslog_cli_traffic=off");
+	VSB_cat(vsb, " -p sigsegv_handler=on");
+	VSB_cat(vsb, " -p thread_pool_min=10");
+	VSB_cat(vsb, " -p debug=+vtc_mode");
+	VSB_cat(vsb, " -p vsl_mask=+Debug");
 	if (!v->has_a_arg) {
 		VSB_printf(vsb, " -a '%s'", "127.0.0.1:0");
 		if (v->proto != NULL)


More information about the varnish-commit mailing list