[master] 8d0000955 Attempt to silence coverity warning
Martin Blix Grydeland
martin at varnish-software.com
Wed Jul 29 13:55:06 UTC 2020
commit 8d00009558559a764d79480143c27fda94f08dc6
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Wed Jul 29 15:52:19 2020 +0200
Attempt to silence coverity warning
Coverity fails to see that with at least 2 OC refs on entry to EXP_Insert,
and one deref if race, then at least one ref remains. Attempt to coerce
acception.
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index c6bb36ef5..ac3594629 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -177,6 +177,7 @@ void
EXP_Insert(struct worker *wrk, struct objcore *oc)
{
unsigned remove_race = 0;
+ struct objcore *tmpoc;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
@@ -186,6 +187,8 @@ EXP_Insert(struct worker *wrk, struct objcore *oc)
if (!(oc->exp_flags & OC_EF_REFD))
return;
+ /* One ref held by the caller, and one that wil be owned by
+ * expiry. */
assert(oc->refcnt >= 2);
ObjSendEvent(wrk, oc, OEV_INSERT);
@@ -204,8 +207,10 @@ EXP_Insert(struct worker *wrk, struct objcore *oc)
if (remove_race) {
ObjSendEvent(wrk, oc, OEV_EXPIRE);
- (void)HSH_DerefObjCore(wrk, &oc, 0);
- AZ(oc);
+ tmpoc = oc;
+ (void)HSH_DerefObjCore(wrk, &tmpoc, 0);
+ AZ(tmpoc);
+ assert(oc->refcnt >= 1); /* Silence coverity */
}
}
More information about the varnish-commit
mailing list