[master] c1cf8d3 Turn the snapshot tokens from WS into uintptr_t to make it very clear that you are not supposed to use them as pointers.

Poul-Henning Kamp phk at FreeBSD.org
Wed Feb 15 12:54:04 CET 2017


commit c1cf8d37ee0f07890e9c763de838130862a71c5f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Feb 15 09:21:33 2017 +0000

    Turn the snapshot tokens from WS into uintptr_t to make it very
    clear that you are not supposed to use them as pointers.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index ddecdf6..cf6e317 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -468,7 +468,7 @@ struct busyobj {
 	struct vfp_ctx		vfc[1];
 
 	struct ws		ws[1];
-	char			*ws_bo;
+	uintptr_t		ws_bo;
 	struct http		*bereq0;
 	struct http		*bereq;
 	struct http		*beresp;
@@ -558,7 +558,7 @@ struct req {
 	const struct director	*director_hint;
 	struct vcl		*vcl;
 
-	char			*ws_req;	/* WS above request data */
+	uintptr_t		ws_req;		/* WS above request data */
 
 	/* Timestamps */
 	double			t_first;	/* First timestamp logged */
@@ -1062,10 +1062,10 @@ void WS_MarkOverflow(struct ws *ws);
 void WS_Release(struct ws *ws, unsigned bytes);
 void WS_ReleaseP(struct ws *ws, char *ptr);
 void WS_Assert(const struct ws *ws);
-void WS_Reset(struct ws *ws, char *p);
+void WS_Reset(struct ws *ws, uintptr_t);
 void *WS_Alloc(struct ws *ws, unsigned bytes);
 void *WS_Copy(struct ws *ws, const void *str, int len);
-char *WS_Snapshot(struct ws *ws);
+uintptr_t WS_Snapshot(struct ws *ws);
 int WS_Overflowed(const struct ws *ws);
 void *WS_Printf(struct ws *ws, const char *fmt, ...) __v_printflike(2, 3);
 
diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c
index fe1598b..0a73e33 100644
--- a/bin/varnishd/cache/cache_req.c
+++ b/bin/varnishd/cache/cache_req.c
@@ -201,8 +201,8 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req)
 		return (1);
 	}
 
-	WS_Reset(req->ws, NULL);
-	WS_Reset(wrk->aws, NULL);
+	WS_Reset(req->ws, 0);
+	WS_Reset(wrk->aws, 0);
 	return (0);
 }
 
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 70de663..4c2e2c6 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -98,7 +98,7 @@ static struct vcl		*vcl_active; /* protected by vcl_mtx */
 static struct vrt_ctx ctx_cli;
 static unsigned handling_cli;
 static struct ws ws_cli;
-static char *ws_snapshot_cli;
+static uintptr_t ws_snapshot_cli;
 
 /*--------------------------------------------------------------------*/
 
@@ -1011,7 +1011,7 @@ static void
 vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
     void *specific, unsigned method, vcl_func_f *func)
 {
-	char *aws;
+	uintptr_t aws;
 	struct vsl_log *vsl = NULL;
 	struct vrt_ctx ctx;
 
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index 47b3fd7..e28d993 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -311,7 +311,7 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk)
 
 		CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 
-		WS_Reset(wrk->aws, NULL);
+		WS_Reset(wrk->aws, 0);
 		AZ(wrk->vsl);
 
 		if (pp->nidle < pool_reserve())
diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c
index bc416c9..be68575 100644
--- a/bin/varnishd/cache/cache_ws.c
+++ b/bin/varnishd/cache/cache_ws.c
@@ -106,10 +106,12 @@ ws_ClearOverflow(struct ws *ws)
  */
 
 void
-WS_Reset(struct ws *ws, char *p)
+WS_Reset(struct ws *ws, uintptr_t pp)
 {
+	char *p;
 
 	WS_Assert(ws);
+	p = (char *)pp;
 	DSL(DBG_WORKSPACE, 0, "WS_Reset(%p, %p)", ws, p);
 	assert(ws->r == NULL);
 	if (p == NULL)
@@ -191,14 +193,14 @@ WS_Printf(struct ws *ws, const char *fmt, ...)
 	return (p);
 }
 
-char *
+uintptr_t
 WS_Snapshot(struct ws *ws)
 {
 
 	WS_Assert(ws);
 	assert(ws->r == NULL);
 	DSL(DBG_WORKSPACE, 0, "WS_Snapshot(%p) = %p", ws, ws->f);
-	return (ws->f);
+	return ((uintptr_t)ws->f);
 }
 
 unsigned
diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c
index 8267fca..756fe81 100644
--- a/bin/varnishd/http1/cache_http1_line.c
+++ b/bin/varnishd/http1/cache_http1_line.c
@@ -60,7 +60,7 @@ struct v1l {
 	struct vsl_log		*vsl;
 	ssize_t			cnt;	/* Flushed byte count */
 	struct ws		*ws;
-	void			*res;
+	uintptr_t		res;
 };
 
 /*--------------------------------------------------------------------
@@ -72,7 +72,7 @@ V1L_Reserve(struct worker *wrk, struct ws *ws, int *fd, struct vsl_log *vsl,
 {
 	struct v1l *v1l;
 	unsigned u;
-	void *res;
+	uintptr_t res;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	AZ(wrk->v1l);
diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index 5acf8a6..82e4f8a 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -690,7 +690,7 @@ h2_new_session(struct worker *wrk, void *arg)
 	struct sess *sp;
 	struct h2_sess *h2;
 	struct h2_req *r2, *r22;
-	char *wsp;
+	uintptr_t wsp;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CAST_OBJ_NOTNULL(req, arg, REQ_MAGIC);
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 8cae9f3..78dc111 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -442,7 +442,7 @@ vmod_workspace_overflowed(VRT_CTX, VCL_ENUM which)
 	return (WS_Overflowed(ws));
 }
 
-static char *debug_ws_snap;
+static uintptr_t debug_ws_snap;
 
 void
 vmod_workspace_snap(VRT_CTX, VCL_ENUM which)



More information about the varnish-commit mailing list