[4.1] 91d56ca Iterate without an extra variable

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Aug 29 13:03:09 CEST 2016


commit 91d56ca02de886c24440cc683eb856e8db3291cc
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Thu Aug 18 19:40:41 2016 +0200

    Iterate without an extra variable

diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c
index 870f46c..952adac 100644
--- a/bin/varnishtest/vtc.c
+++ b/bin/varnishtest/vtc.c
@@ -569,60 +569,61 @@ cmd_random(CMD_ARGS)
 static void
 cmd_feature(CMD_ARGS)
 {
-	int i, r;
+	int r;
 
 	(void)priv;
 	(void)cmd;
+
 	if (av == NULL)
 		return;
 
-	for (i = 1; av[i] != NULL; i++) {
+	for (; *av != NULL; av++) {
 #ifdef SO_RCVTIMEO_WORKS
-		if (!strcmp(av[i], "SO_RCVTIMEO_WORKS"))
+		if (!strcmp(*av, "SO_RCVTIMEO_WORKS"))
 			continue;
 #endif
-		if (sizeof(void*) == 8 && !strcmp(av[i], "64bit"))
+		if (sizeof(void*) == 8 && !strcmp(*av, "64bit"))
 			continue;
 
-		if (!strcmp(av[i], "pcre_jit") && VRE_has_jit)
+		if (!strcmp(*av, "pcre_jit") && VRE_has_jit)
 			continue;
 
-		if (!strcmp(av[i], "!OSX")) {
+		if (!strcmp(*av, "!OSX")) {
 #if !defined(__APPLE__) || !defined(__MACH__)
 			continue;
 #endif
 		}
-		if (!strcmp(av[i], "dns") && feature_dns)
+		if (!strcmp(*av, "dns") && feature_dns)
 			continue;
 
-		if (!strcmp(av[i], "topbuild") && iflg)
+		if (!strcmp(*av, "topbuild") && iflg)
 			continue;
 
-		if (!strcmp(av[i], "root") && !geteuid())
+		if (!strcmp(*av, "root") && !geteuid())
 			continue;
 
-		if (!strcmp(av[i], "user_varnish") &&
+		if (!strcmp(*av, "user_varnish") &&
 		    getpwnam("varnish") != NULL)
 			continue;
 
-		if (!strcmp(av[i], "user_vcache") &&
+		if (!strcmp(*av, "user_vcache") &&
 		    getpwnam("vcache") != NULL)
 			continue;
 
-		if (!strcmp(av[i], "group_varnish") &&
+		if (!strcmp(*av, "group_varnish") &&
 		    getgrnam("varnish") != NULL)
 			continue;
 
-		if (!strcmp(av[i], "cmd")) {
-			i++;
-			if (av[i] == NULL)
+		if (!strcmp(*av, "cmd")) {
+			av++;
+			if (*av == NULL)
 				vtc_log(vl, 0, "Missing the command-line");
-			r = system(av[i]);
+			r = system(*av);
 			if (WEXITSTATUS(r) == 0)
 				continue;
 		}
 
-		vtc_log(vl, 1, "SKIPPING test, missing feature: %s", av[i]);
+		vtc_log(vl, 1, "SKIPPING test, missing feature: %s", *av);
 		vtc_stop = 1;
 		return;
 	}



More information about the varnish-commit mailing list