[6.0] 691b07328 Avoid printing %s, NULL in case of errors we do not expect.

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Thu Jun 27 17:05:11 UTC 2019


commit 691b073287917899c54cf89258b3b4ac281b1e57
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Jan 11 10:26:44 2019 +0000

    Avoid printing %s,NULL in case of errors we do not expect.
    
    Fixes #2879

diff --git a/lib/libvarnish/vnum.c b/lib/libvarnish/vnum.c
index b619199c6..59e804ec8 100644
--- a/lib/libvarnish/vnum.c
+++ b/lib/libvarnish/vnum.c
@@ -349,15 +349,17 @@ main(int argc, char *argv[])
 
 	for (tc = test_cases; tc->str; ++tc) {
 		e = VNUM_2bytes(tc->str, &val, tc->rel);
-		if (e != tc->err) {
-			printf("%s: VNUM_2bytes(\"%s\", %ju) (%s) != (%s)\n",
-			    *argv, tc->str, tc->rel, tc->err, e);
-			++ec;
-		} else if (e == NULL && val != tc->val) {
-			printf("%s: VNUM_2bytes(\"%s\", %ju) %ju != %ju (%s)\n",
-			    *argv, tc->str, tc->rel, val, tc->val, e);
-			++ec;
-		}
+		if (e != NULL)
+			val = 0;
+		if (e == tc->err && val == tc->val)
+			continue;
+		++ec;
+		printf("%s: VNUM_2bytes(\"%s\", %ju)\n",
+		   *argv, tc->str, tc->rel);
+		printf("\tExpected:\tstatus %s - value %ju\n",
+		    tc->err ? tc->err : "Success", tc->val);
+		printf("\tGot:\t\tstatus %s - value %ju\n",
+		    e ? e : "Success", val);
 	}
 	if (!isnan(VNUM_duration(NULL))) {
 		printf("%s: VNUM_Duration(NULL) fail\n", *argv);


More information about the varnish-commit mailing list