[master] ac41f195b Revert "cache_ban: Flexelint banidx"

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Thu Apr 17 11:03:04 UTC 2025


commit ac41f195b83df7a6db5df3e7c6f97a0af469f668
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Thu Apr 17 12:55:46 2025 +0200

    Revert "cache_ban: Flexelint banidx"
    
    This reverts commit 30fca975e4e596a541106997f5cf5f282da164ac.

diff --git a/bin/varnishd/cache/cache_ban_idx.c b/bin/varnishd/cache/cache_ban_idx.c
index 7857ffb20..11a5886a0 100644
--- a/bin/varnishd/cache/cache_ban_idx.c
+++ b/bin/varnishd/cache/cache_ban_idx.c
@@ -44,6 +44,9 @@
 
 #include "cache_varnishd.h"
 #include "cache_ban.h"
+#include "cache_objhead.h"
+
+#include "vtree.h"
 
 struct metaban {
 	unsigned		magic;
@@ -55,7 +58,7 @@ struct metaban {
 };
 
 static inline int
-metaban_cmp(const struct metaban *i1, const struct metaban *i2)
+metaban_cmp(const struct metaban *i1, struct metaban *i2)
 {
 	if (i1->time < i2->time)
 		return (-1);
@@ -64,33 +67,10 @@ metaban_cmp(const struct metaban *i1, const struct metaban *i2)
 	return (0);
 }
 
-/* why does vtree.h not declare name and elm const ? */
-#define VRBT_GENERATE_NFINDc(name, type, field, cmp, attr)		\
-/* Finds the first node greater than or equal to the search key */	\
-attr struct type *							\
-name##_VRBT_NFIND(const struct name *head, const struct type *elm)	\
-{									\
-	struct type *tmp = VRBT_ROOT(head);				\
-	struct type *res = NULL;					\
-	__typeof(cmp(NULL, NULL)) comp;					\
-	while (tmp) {							\
-		comp = cmp(elm, tmp);					\
-		if (comp < 0) {						\
-			res = tmp;					\
-			tmp = VRBT_LEFT(tmp, field);			\
-		}							\
-		else if (comp > 0)					\
-			tmp = VRBT_RIGHT(tmp, field);			\
-		else							\
-			return (tmp);					\
-	}								\
-	return (res);							\
-}
-
 VRBT_HEAD(banidx_s, metaban);
 VRBT_GENERATE_REMOVE_COLOR(banidx_s, metaban, tree, static)
 VRBT_GENERATE_REMOVE(banidx_s, metaban, tree, static)
-VRBT_GENERATE_NFINDc(banidx_s, metaban, tree, metaban_cmp, static)
+VRBT_GENERATE_NFIND(banidx_s, metaban, tree, metaban_cmp, static)
 VRBT_GENERATE_INSERT_COLOR(banidx_s, metaban, tree, static)
 VRBT_GENERATE_INSERT_FINISH(banidx_s, metaban, tree, static)
 VRBT_GENERATE_INSERT(banidx_s, metaban, tree, metaban_cmp, static)
@@ -103,8 +83,7 @@ static pthread_mutex_t banidxmtx = PTHREAD_MUTEX_INITIALIZER;
 struct ban *
 BANIDX_lookup(vtim_real t0)
 {
-	struct metaban *m;	//lint -e429 not freed or returned
-	struct metaban needle = {0, .time = t0};
+	struct metaban *m, needle = {0, .time = t0};
 	struct ban *best = NULL, *b = NULL;
 	vtim_real t1;
 
@@ -135,7 +114,6 @@ BANIDX_lookup(vtim_real t0)
 		if (t1 < t0)
 			break;
 		ALLOC_OBJ(m, BANIDX_MAGIC);
-		AN(m);
 		m->time = t1;
 		m->ban = b;
 		AZ(VRBT_INSERT(banidx_s, &banidx, m));


More information about the varnish-commit mailing list