[master] 940ba5763 Flip sense of test, hoping compilers will then not be upset about asserts not happening.

Poul-Henning Kamp phk at FreeBSD.org
Mon Nov 11 09:13:05 UTC 2019


commit 940ba5763037c0020d1bb6bb442b800fcc8e7332
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Nov 11 09:12:16 2019 +0000

    Flip sense of test, hoping compilers will then not be upset about asserts not happening.

diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index c94ad1f11..3548d6c57 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -151,14 +151,14 @@ SES_Set_String_Attr(struct sess *sp, enum sess_attr a, const char *src)
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	AN(src);
 
-	/*lint -save -e568 -e685 */
-
+	/*lint -save -e506 -e774 */
 	switch (a) {
-#define SESS_ATTR(UP, low, typ, len)	case SA_##UP: assert(len < 0); break;
+#define SESS_ATTR(UP, low, typ, len) \
+		case SA_##UP: if (len > 0) WRONG("wrong: " #UP); break;
 #include "tbl/sess_attr.h"
-	default:  WRONG("wrong sess_attr");
+		default:
+			WRONG("wrong sess_attr");
 	}
-
 	/*lint -restore */
 
 	ses_reserve_attr(sp, a, &q, strlen(src) + 1);
@@ -172,14 +172,14 @@ SES_Get_String_Attr(const struct sess *sp, enum sess_attr a)
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 
-	/*lint -save -e568 -e685 */
-
+	/*lint -save -e506 -e774 */
 	switch (a) {
-#define SESS_ATTR(UP, low, typ, len)	case SA_##UP: assert(len < 0); break;
+#define SESS_ATTR(UP, low, typ, len) \
+		case SA_##UP: if (len > 0) WRONG("wrong: " #UP); break;
 #include "tbl/sess_attr.h"
-	default:  WRONG("wrong sess_attr");
+		default:
+			WRONG("wrong sess_attr");
 	}
-
 	/*lint -restore */
 
 	if (ses_get_attr(sp, a, &q) < 0)


More information about the varnish-commit mailing list