[master] 503e231ba Result of coccinelle script from previous commit

Nils Goroll nils.goroll at uplex.de
Mon Aug 15 13:38:05 UTC 2022


commit 503e231baa6f1282256ef7ea133528c532725c5f
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Aug 15 15:24:27 2022 +0200

    Result of coccinelle script from previous commit

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 11b7e5044..56fef17c6 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -408,10 +408,12 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 
 	VCL_backend_fetch_method(bo->vcl, wrk, NULL, bo, NULL);
 
-	if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL)
+	if (wrk->vpi->handling == VCL_RET_ABANDON ||
+	    wrk->vpi->handling == VCL_RET_FAIL)
 		return (F_STP_FAIL);
 
-	assert (wrk->handling == VCL_RET_FETCH || wrk->handling == VCL_RET_ERROR);
+	assert (wrk->vpi->handling == VCL_RET_FETCH ||
+	    wrk->vpi->handling == VCL_RET_ERROR);
 
 	HTTP_Setup(bo->beresp, bo->ws, bo->vsl, SLT_BerespMethod);
 
@@ -424,7 +426,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 	bo->vfc->resp = bo->beresp;
 	bo->vfc->req = bo->bereq;
 
-	if (wrk->handling == VCL_RET_ERROR)
+	if (wrk->vpi->handling == VCL_RET_ERROR)
 		return (F_STP_ERROR);
 
 	VSLb_ts_busyobj(bo, "Fetch", W_TIM_real(wrk));
@@ -501,24 +503,25 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 		return (F_STP_ERROR);
 	}
 
-	if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL ||
-	    wrk->handling == VCL_RET_ERROR) {
+	if (wrk->vpi->handling == VCL_RET_ABANDON ||
+	    wrk->vpi->handling == VCL_RET_FAIL ||
+	    wrk->vpi->handling == VCL_RET_ERROR) {
 		/* do not count deliberately ending the backend connection as
 		 * fetch failure
 		 */
-		handling = wrk->handling;
+		handling = wrk->vpi->handling;
 		if (bo->htc)
 			bo->htc->doclose = SC_RESP_CLOSE;
 		vbf_cleanup(bo);
-		wrk->handling = handling;
+		wrk->vpi->handling = handling;
 
-		if (wrk->handling == VCL_RET_ERROR)
+		if (wrk->vpi->handling == VCL_RET_ERROR)
 			return (F_STP_ERROR);
 		else
 			return (F_STP_FAIL);
 	}
 
-	if (wrk->handling == VCL_RET_RETRY) {
+	if (wrk->vpi->handling == VCL_RET_RETRY) {
 		if (bo->htc && bo->htc->body_status != BS_NONE)
 			bo->htc->doclose = SC_RESP_CLOSE;
 		vbf_cleanup(bo);
@@ -541,15 +544,15 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 
 	if (bo->do_esi)
 		bo->do_stream = 0;
-	if (wrk->handling == VCL_RET_PASS) {
+	if (wrk->vpi->handling == VCL_RET_PASS) {
 		oc->flags |= OC_F_HFP;
 		bo->uncacheable = 1;
-		wrk->handling = VCL_RET_DELIVER;
+		wrk->vpi->handling = VCL_RET_DELIVER;
 	}
 	if (bo->uncacheable)
 		oc->flags |= OC_F_HFM;
 
-	assert(wrk->handling == VCL_RET_DELIVER);
+	assert(wrk->vpi->handling == VCL_RET_DELIVER);
 
 	return (bo->was_304 ? F_STP_CONDFETCH : F_STP_FETCH);
 }
@@ -639,7 +642,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 	oc = bo->fetch_objcore;
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 
-	assert(wrk->handling == VCL_RET_DELIVER);
+	assert(wrk->vpi->handling == VCL_RET_DELIVER);
 
 	if (bo->htc == NULL) {
 		(void)VFP_Error(bo->vfc, "No backend connection (rollback?)");
@@ -888,7 +891,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
 	AN(oc->flags & OC_F_BUSY);
 	assert(bo->director_state == DIR_S_NULL);
 
-	if (wrk->handling != VCL_RET_ERROR)
+	if (wrk->vpi->handling != VCL_RET_ERROR)
 		wrk->stats->fetch_failed++;
 
 	now = W_TIM_real(wrk);
@@ -942,12 +945,12 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
 
 	AZ(VSB_finish(synth_body));
 
-	if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL) {
+	if (wrk->vpi->handling == VCL_RET_ABANDON || wrk->vpi->handling == VCL_RET_FAIL) {
 		VSB_destroy(&synth_body);
 		return (F_STP_FAIL);
 	}
 
-	if (wrk->handling == VCL_RET_RETRY) {
+	if (wrk->vpi->handling == VCL_RET_RETRY) {
 		VSB_destroy(&synth_body);
 		if (bo->retries++ < cache_param->max_retries)
 			return (F_STP_RETRY);
@@ -955,7 +958,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
 		return (F_STP_FAIL);
 	}
 
-	assert(wrk->handling == VCL_RET_DELIVER);
+	assert(wrk->vpi->handling == VCL_RET_DELIVER);
 
 	assert(bo->vfc->wrk == bo->wrk);
 	assert(bo->vfc->oc == oc);
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index dd288c1f6..8b5e33a75 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -297,11 +297,11 @@ pan_wrk(struct vsb *vsb, const struct worker *wrk)
 	else
 		VSB_printf(vsb, "0x%x,\n", m);
 
-	hand = VCL_Return_Name(wrk->handling);
+	hand = VCL_Return_Name(wrk->vpi->handling);
 	if (hand != NULL)
 		VSB_printf(vsb, "VCL::return = %s,\n", hand);
 	else
-		VSB_printf(vsb, "VCL::return = 0x%x,\n", wrk->handling);
+		VSB_printf(vsb, "VCL::return = 0x%x,\n", wrk->vpi->handling);
 	VSB_cat(vsb, "VCL::methods = {");
 	m = wrk->seen_methods;
 	p = "";
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 48f5d5c7b..95c108789 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -239,12 +239,12 @@ cnt_deliver(struct worker *wrk, struct req *req)
 
 	assert(req->restarts <= cache_param->max_restarts);
 
-	if (wrk->handling != VCL_RET_DELIVER) {
+	if (wrk->vpi->handling != VCL_RET_DELIVER) {
 		HSH_Cancel(wrk, req->objcore, NULL);
 		(void)HSH_DerefObjCore(wrk, &req->objcore, HSH_RUSH_POLICY);
 		http_Teardown(req->resp);
 
-		switch (wrk->handling) {
+		switch (wrk->vpi->handling) {
 		case VCL_RET_RESTART:
 			req->req_step = R_STP_RESTART;
 			break;
@@ -261,7 +261,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
 		return (REQ_FSM_MORE);
 	}
 
-	assert(wrk->handling == VCL_RET_DELIVER);
+	assert(wrk->vpi->handling == VCL_RET_DELIVER);
 
 	if (IS_TOPREQ(req) && RFC2616_Do_Cond(req))
 		http_PutResponse(req->resp, "HTTP/1.1", 304, NULL);
@@ -334,7 +334,7 @@ cnt_synth(struct worker *wrk, struct req *req)
 
 	VSLb_ts_req(req, "Process", W_TIM_real(wrk));
 
-	if (wrk->handling == VCL_RET_FAIL) {
+	if (wrk->vpi->handling == VCL_RET_FAIL) {
 		VSB_destroy(&synth_body);
 		(void)VRB_Ignore(req);
 		(void)req->transport->minimal_response(req, 500);
@@ -344,11 +344,11 @@ cnt_synth(struct worker *wrk, struct req *req)
 		return (REQ_FSM_DONE);
 	}
 
-	if (wrk->handling == VCL_RET_RESTART &&
+	if (wrk->vpi->handling == VCL_RET_RESTART &&
 	    req->restarts > cache_param->max_restarts)
-		wrk->handling = VCL_RET_DELIVER;
+		wrk->vpi->handling = VCL_RET_DELIVER;
 
-	if (wrk->handling == VCL_RET_RESTART) {
+	if (wrk->vpi->handling == VCL_RET_RESTART) {
 		/*
 		 * XXX: Should we reset req->doclose = SC_VCL_FAILURE
 		 * XXX: If so, to what ?
@@ -358,7 +358,7 @@ cnt_synth(struct worker *wrk, struct req *req)
 		req->req_step = R_STP_RESTART;
 		return (REQ_FSM_MORE);
 	}
-	assert(wrk->handling == VCL_RET_DELIVER);
+	assert(wrk->vpi->handling == VCL_RET_DELIVER);
 
 	http_Unset(req->resp, H_Content_Length);
 	http_PrintfHeader(req->resp, "Content-Length: %zd",
@@ -618,7 +618,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
 
 	VCL_hit_method(req->vcl, wrk, req, NULL, NULL);
 
-	switch (wrk->handling) {
+	switch (wrk->vpi->handling) {
 	case VCL_RET_DELIVER:
 		if (busy != NULL) {
 			AZ(oc->flags & OC_F_HFM);
@@ -680,7 +680,7 @@ cnt_miss(struct worker *wrk, struct req *req)
 	CHECK_OBJ_ORNULL(req->stale_oc, OBJCORE_MAGIC);
 
 	VCL_miss_method(req->vcl, wrk, req, NULL, NULL);
-	switch (wrk->handling) {
+	switch (wrk->vpi->handling) {
 	case VCL_RET_FETCH:
 		wrk->stats->cache_miss++;
 		VBF_Fetch(wrk, req, req->objcore, req->stale_oc, VBF_NORMAL);
@@ -725,7 +725,7 @@ cnt_pass(struct worker *wrk, struct req *req)
 	AZ(req->stale_oc);
 
 	VCL_pass_method(req->vcl, wrk, req, NULL, NULL);
-	switch (wrk->handling) {
+	switch (wrk->vpi->handling) {
 	case VCL_RET_FAIL:
 		req->req_step = R_STP_VCLFAIL;
 		break;
@@ -786,11 +786,11 @@ cnt_pipe(struct worker *wrk, struct req *req)
 
 	bo->wrk = wrk;
 	if (WS_Overflowed(req->ws))
-		wrk->handling = VCL_RET_FAIL;
+		wrk->vpi->handling = VCL_RET_FAIL;
 	else
 		VCL_pipe_method(req->vcl, wrk, req, bo, NULL);
 
-	switch (wrk->handling) {
+	switch (wrk->vpi->handling) {
 	case VCL_RET_SYNTH:
 		req->req_step = R_STP_SYNTH;
 		nxt = REQ_FSM_MORE;
@@ -954,12 +954,12 @@ cnt_recv(struct worker *wrk, struct req *req)
 
 	VCL_recv_method(req->vcl, wrk, req, NULL, NULL);
 
-	if (wrk->handling == VCL_RET_FAIL) {
+	if (wrk->vpi->handling == VCL_RET_FAIL) {
 		req->req_step = R_STP_VCLFAIL;
 		return (REQ_FSM_MORE);
 	}
 
-	if (wrk->handling == VCL_RET_VCL && req->restarts == 0) {
+	if (wrk->vpi->handling == VCL_RET_VCL && req->restarts == 0) {
 		// Req_Rollback has happened in VPI_vcl_select
 		assert(WS_Snapshot(req->ws) == req->ws_req);
 		cnt_recv_prep(req, ci);
@@ -980,7 +980,7 @@ cnt_recv(struct worker *wrk, struct req *req)
 		return (REQ_FSM_DONE);
 	}
 
-	recv_handling = wrk->handling;
+	recv_handling = wrk->vpi->handling;
 
 	/* We wash the A-E header here for the sake of VRY */
 	if (cache_param->http_gzip_support &&
@@ -995,10 +995,10 @@ cnt_recv(struct worker *wrk, struct req *req)
 
 	VSHA256_Init(&sha256ctx);
 	VCL_hash_method(req->vcl, wrk, req, NULL, &sha256ctx);
-	if (wrk->handling == VCL_RET_FAIL)
-		recv_handling = wrk->handling;
+	if (wrk->vpi->handling == VCL_RET_FAIL)
+		recv_handling = wrk->vpi->handling;
 	else
-		assert(wrk->handling == VCL_RET_LOOKUP);
+		assert(wrk->vpi->handling == VCL_RET_LOOKUP);
 	VSHA256_Final(req->digest, &sha256ctx);
 
 	switch (recv_handling) {
@@ -1083,7 +1083,7 @@ cnt_purge(struct worker *wrk, struct req *req)
 	AZ(HSH_DerefObjCore(wrk, &boc, 1));
 
 	VCL_purge_method(req->vcl, wrk, req, NULL, NULL);
-	switch (wrk->handling) {
+	switch (wrk->vpi->handling) {
 	case VCL_RET_RESTART:
 		req->req_step = R_STP_RESTART;
 		break;
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 97490920d..8251e149a 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -91,8 +91,8 @@ VCL_Bo2Ctx(struct vrt_ctx *ctx, struct busyobj *bo)
 	ctx->sp = bo->sp;
 	ctx->now = bo->t_prev;
 	ctx->ws = bo->ws;
-	ctx->handling = &bo->wrk->handling;
-	*ctx->handling = 0;
+	ctx->vpi = bo->wrk->vpi;
+	ctx->vpi->handling = 0;
 }
 
 void
@@ -114,8 +114,8 @@ VCL_Req2Ctx(struct vrt_ctx *ctx, struct req *req)
 	ctx->sp = req->sp;
 	ctx->now = req->t_prev;
 	ctx->ws = req->ws;
-	ctx->handling = &req->wrk->handling;
-	*ctx->handling = 0;
+	ctx->vpi = req->wrk->vpi;
+	ctx->vpi->handling = 0;
 }
 
 /*--------------------------------------------------------------------*/
@@ -186,10 +186,10 @@ vcl_event_handling(VRT_CTX)
 {
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
 
-	if (*ctx->handling == 0)
+	if (ctx->vpi->handling == 0)
 		return (0);
 
-	assert(*ctx->handling == VCL_RET_FAIL);
+	assert(ctx->vpi->handling == VCL_RET_FAIL);
 
 	if (ctx->method == VCL_MET_INIT)
 		return (1);
@@ -200,7 +200,7 @@ vcl_event_handling(VRT_CTX)
 	 */
 	assert(ctx->method == VCL_MET_FINI);
 
-	*ctx->handling = 0;
+	ctx->vpi->handling = 0;
 	VRT_fail(ctx, "VRT_fail() from vcl_fini{} has no effect");
 	return (0);
 }
@@ -239,8 +239,8 @@ vcl_send_event(struct vcl *vcl, enum vcl_event_e ev, struct vsb **msg)
 
 	ctx = VCL_Get_CliCtx(havemsg);
 
-	AN(ctx->handling);
-	AZ(*ctx->handling);
+	AN(ctx->vpi);
+	AZ(ctx->vpi->handling);
 	AN(ctx->ws);
 
 	ctx->vcl = vcl;
diff --git a/bin/varnishd/cache/cache_vpi.c b/bin/varnishd/cache/cache_vpi.c
index d2b149701..302523c39 100644
--- a/bin/varnishd/cache/cache_vpi.c
+++ b/bin/varnishd/cache/cache_vpi.c
@@ -89,12 +89,12 @@ void
 VPI_vcl_fini(VRT_CTX)
 {
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
-	AN(ctx->handling);
+	AN(ctx->vpi);
 
-	if (*ctx->handling == VCL_RET_FAIL)
+	if (ctx->vpi->handling == VCL_RET_FAIL)
 		return;
-	assert(*ctx->handling == VCL_RET_OK);
-	*ctx->handling = 0;
+	assert(ctx->vpi->handling == VCL_RET_OK);
+	ctx->vpi->handling = 0;
 }
 
 VCL_VCL
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index dff0692af..f6c427ad1 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -643,19 +643,19 @@ VRT_handling(VRT_CTX, unsigned hand)
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
 	assert(hand != VCL_RET_FAIL);
-	AN(ctx->handling);
-	AZ(*ctx->handling);
+	AN(ctx->vpi);
+	AZ(ctx->vpi->handling);
 	assert(hand > 0);
 	assert(hand < VCL_RET_MAX);
-	*ctx->handling = hand;
+	ctx->vpi->handling = hand;
 }
 
 unsigned
 VRT_handled(VRT_CTX)
 {
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
-	AN(ctx->handling);
-	return (*ctx->handling);
+	AN(ctx->vpi);
+	return (ctx->vpi->handling);
 }
 
 /*--------------------------------------------------------------------*/
@@ -667,10 +667,10 @@ VRT_fail(VRT_CTX, const char *fmt, ...)
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
 	assert(ctx->vsl != NULL || ctx->msg != NULL);
-	AN(ctx->handling);
-	if (*ctx->handling == VCL_RET_FAIL)
+	AN(ctx->vpi);
+	if (ctx->vpi->handling == VCL_RET_FAIL)
 		return;
-	AZ(*ctx->handling);
+	AZ(ctx->vpi->handling);
 	AN(fmt);
 	AZ(strchr(fmt, '\n'));
 	va_start(ap, fmt);
@@ -682,7 +682,7 @@ VRT_fail(VRT_CTX, const char *fmt, ...)
 		VSB_putc(ctx->msg, '\n');
 	}
 	va_end(ap);
-	*ctx->handling = VCL_RET_FAIL;
+	ctx->vpi->handling = VCL_RET_FAIL;
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c
index 685bb451c..fd4e84fbc 100644
--- a/bin/varnishd/cache/cache_vrt_priv.c
+++ b/bin/varnishd/cache/cache_vrt_priv.c
@@ -280,7 +280,7 @@ VRT_priv_fini(VRT_CTX, const struct vmod_priv *p)
 	VRT_CTX_Assert(ctx);
 
 	m->fini(ctx, p->priv);
-	assert(*ctx->handling == 0 || *ctx->handling == VCL_RET_FAIL);
+	assert(ctx->vpi->handling == 0 || ctx->vpi->handling == VCL_RET_FAIL);
 }
 
 /*--------------------------------------------------------------------*/
@@ -298,8 +298,8 @@ VCL_TaskLeave(VRT_CTX, struct vrt_privs *privs)
 	struct vrt_priv *vp, *vp1;
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
-	AN(ctx->handling);
-	assert(*ctx->handling == 0 || *ctx->handling == VCL_RET_FAIL);
+	AN(ctx->vpi);
+	assert(ctx->vpi->handling == 0 || ctx->vpi->handling == VCL_RET_FAIL);
 
 	/*
 	 * NB: We don't bother removing entries as we finish them because it's
diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c
index 976930e4e..56ad0340e 100644
--- a/bin/varnishd/cache/cache_vrt_vcl.c
+++ b/bin/varnishd/cache/cache_vrt_vcl.c
@@ -558,9 +558,9 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
 	VSLbs(ctx.vsl, SLT_VCL_call, TOSTRAND(VCL_Method_Name(method)));
 	func(&ctx, VSUB_STATIC, NULL);
 	VSLbs(ctx.vsl, SLT_VCL_return,
-	    TOSTRAND(VCL_Return_Name(wrk->handling)));
+	    TOSTRAND(VCL_Return_Name(wrk->vpi->handling)));
 	wrk->cur_method |= 1;		// Magic marker
-	if (wrk->handling == VCL_RET_FAIL)
+	if (wrk->vpi->handling == VCL_RET_FAIL)
 		wrk->stats->vcl_fail++;
 
 	/*


More information about the varnish-commit mailing list