r5566 - trunk/varnish-cache/bin/varnishd

phk at varnish-cache.org phk at varnish-cache.org
Sun Nov 21 10:08:30 CET 2010


Author: phk
Date: 2010-11-21 10:08:29 +0100 (Sun, 21 Nov 2010)
New Revision: 5566

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/storage_persistent.c
Log:
Avoid a couple of nasty casts by simply making oc->priv2 an integer.
Only -spersistent needs it yet and we can generalize should the need
ever materialize.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2010-11-20 23:59:48 UTC (rev 5565)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2010-11-21 09:08:29 UTC (rev 5566)
@@ -321,7 +321,7 @@
 	unsigned		refcnt;
 	struct objcore_methods	*methods;
 	void			*priv;
-	void			*priv2;
+	unsigned		priv2;
 	struct objhead		*objhead;
 	double			timer_when;
 	unsigned		flags;

Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_persistent.c	2010-11-20 23:59:48 UTC (rev 5565)
+++ trunk/varnish-cache/bin/varnishd/storage_persistent.c	2010-11-21 09:08:29 UTC (rev 5566)
@@ -662,8 +662,8 @@
 	if (wrk == NULL)
 		AZ(oc->flags & OC_F_NEEDFIXUP);
 
-	CAST_OBJ_NOTNULL(sg, oc->priv2, SMP_SEG_MAGIC);
-	smp_index = (uintptr_t) oc->priv;
+	CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC);
+	smp_index = oc->priv2;
 	assert(smp_index < sg->nalloc2);
 
 	o = sg->objs[smp_index].ptr;
@@ -702,7 +702,7 @@
 	o = smp_oc_getobj(NULL, oc);
 	AN(o);
 	
-	CAST_OBJ_NOTNULL(sg, oc->priv2, SMP_SEG_MAGIC);
+	CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC);
 	CHECK_OBJ_NOTNULL(sg->sc, SMP_SC_MAGIC);
 
 	if (sg == sg->sc->cur_seg) {
@@ -727,7 +727,7 @@
 	o = smp_oc_getobj(NULL, oc);
 	AN(o);
 
-	CAST_OBJ_NOTNULL(sg, oc->priv2, SMP_SEG_MAGIC);
+	CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC);
 
 	Lck_Lock(&sg->sc->mtx);
 	sg->objs[o->smp_index].ttl = 0;
@@ -914,8 +914,8 @@
 		oc = sp->wrk->nobjcore;
 		oc->flags |= OC_F_NEEDFIXUP | OC_F_LRUDONTMOVE;
 		oc->flags &= ~OC_F_BUSY;
-		oc->priv = (void*)(uintptr_t)n;
-		oc->priv2 = sg;
+		oc->priv = sg;
+		oc->priv2 = n;
 		oc->methods = &smp_oc_methods;
 		oc->ban = BAN_RefBan(oc, so->ban, sc->tailban);
 		memcpy(sp->wrk->nobjhead->digest, so->hash, SHA256_LEN);
@@ -1450,8 +1450,8 @@
 	so->ptr = o;
 	so->ban = o->ban_t;
 
-	oc->priv = (void*)(uintptr_t)(o->smp_index);
-	oc->priv2 = sg;
+	oc->priv = sg;
+	oc->priv2 = o->smp_index;
 	oc->methods = &smp_oc_methods;
 
 	Lck_Unlock(&sc->mtx);




More information about the varnish-commit mailing list