Rename bytes_tree struct member to reduce confusion using the coccinelle script

parent d8c5e5c5
@@
struct pesi_tree *ptr;
@@
- ptr->tree
+ ptr->bytes_tree
@@
struct pesi *pesi;
@@
- pesi->pesi_tree->tree
+ pesi->pesi_tree->bytes_tree
@@
struct pesi_tree val;
@@
- val.tree
+ val.bytes_tree
\ No newline at end of file
#!/bin/bash
function usage() {
cat <<EOF
Usage: $0 <sp-file> <spatch-arguments>
Examples:
* apply
$0 my.cocci --dir . --in-place
* expand a patch
$0 my.cocci --parse-cocci
EOF
}
if [[ ${#@} -lt 1 ]] ; then
usage
exit
fi
if [[ -z "${VARNISHSRC}" ]] ; then
echo VARNISHSRC must be set, pointing to the Varnish-Cache source tree
exit
fi
cocci="${1}"
shift
spatch=(
spatch
--macro-file ${VARNISHSRC}/tools/coccinelle/vdef.h
-I ${VARNISHSRC}/include/
-I ${VARNISHSRC}/bin/varnishd/ "${@}"
--sp-file "${cocci}"
)
exec "${spatch[@]}"
......@@ -34,7 +34,7 @@
struct pesi_tree {
unsigned magic;
#define PESI_TREE_MAGIC 0xe8ce8adb
struct bytes_tree *tree;
struct bytes_tree *bytes_tree;
/* all pesis (struct pesi) we started */
struct lock task_lock;
......
/*-
* Copyright 2019 - 2021 UPLEX Nils Goroll Systemoptimierung
* Copyright 2019 - 2021, 2023 UPLEX Nils Goroll Systemoptimierung
* All rights reserved
*
* Authors: Geoffrey Simmons <geoffrey.simmons@uplex.de>
......@@ -170,7 +170,7 @@ vped_task(struct worker *wrk, void *priv)
pesi->wrk = wrk;
node = pesi->node;
CHECK_OBJ_NOTNULL(node, NODE_MAGIC);
CHECK_OBJ_NOTNULL(pesi_tree->tree, BYTES_TREE_MAGIC);
CHECK_OBJ_NOTNULL(pesi_tree->bytes_tree, BYTES_TREE_MAGIC);
THR_SetRequest(req);
VSLb_ts_req(req, "Start", W_TIM_real(wrk));
......@@ -230,11 +230,11 @@ vped_task(struct worker *wrk, void *priv)
break;
case T_SUBREQ:
assert(pesi == req->transport_priv);
Lck_Lock(&pesi_tree->tree->tree_lock);
Lck_Lock(&pesi_tree->bytes_tree->tree_lock);
task_fini(pesi_tree, pesi);
node->subreq.done = 1;
AZ(pthread_cond_signal(&node->subreq.cond));
Lck_Unlock(&pesi_tree->tree->tree_lock);
Lck_Unlock(&pesi_tree->bytes_tree->tree_lock);
break;
case T_NEXUS:
assert(node->nexus.req == req);
......@@ -250,9 +250,9 @@ vped_task(struct worker *wrk, void *priv)
AZ(req->transport_priv);
pesi = NULL;
Lck_Lock(&pesi_tree->tree->tree_lock);
set_closed(pesi_tree->tree, node, wrk);
Lck_Unlock(&pesi_tree->tree->tree_lock);
Lck_Lock(&pesi_tree->bytes_tree->tree_lock);
set_closed(pesi_tree->bytes_tree, node, wrk);
Lck_Unlock(&pesi_tree->bytes_tree->tree_lock);
AZ(pesi);
task_fini(pesi_tree, pesi);
break;
......@@ -286,12 +286,12 @@ vped_task(struct worker *wrk, void *priv)
req_fini(&node->nexus.req, wrk);
/* turn into T_DATA node */
node_mutate_prep(pesi_tree->tree, node);
node_mutate_prep(pesi_tree->bytes_tree, node);
memset(&node->data, 0, sizeof node->data);
node_mutate_lock(pesi_tree->tree, node,
T_DATA, ST_DATA);
node_mutate_unlock(pesi_tree->tree);
node_mutate_lock(pesi_tree->bytes_tree, node,
T_DATA, ST_DATA);
node_mutate_unlock(pesi_tree->bytes_tree);
task_fini(pesi_tree, pesi);
break;
......@@ -323,7 +323,7 @@ vped_include(struct req *preq, const char *src, const char *host,
CHECK_OBJ_NOTNULL(pesi, PESI_MAGIC);
pesi_tree = pesi->pesi_tree;
CHECK_OBJ_NOTNULL(pesi_tree, PESI_TREE_MAGIC);
tree = pesi_tree->tree;
tree = pesi_tree->bytes_tree;
CHECK_OBJ_NOTNULL(tree, BYTES_TREE_MAGIC);
CHECK_OBJ_NOTNULL(node, NODE_MAGIC);
wrk = preq->wrk;
......@@ -525,7 +525,7 @@ pesi_buf_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
CAST_OBJ_NOTNULL(pesi, *priv, PESI_MAGIC);
CHECK_OBJ_NOTNULL(pesi->pesi_tree, PESI_TREE_MAGIC);
tree = pesi->pesi_tree->tree;
tree = pesi->pesi_tree->bytes_tree;
CHECK_OBJ_NOTNULL(tree, BYTES_TREE_MAGIC);
if (tree->retval || ptr == NULL || len == 0)
......@@ -701,13 +701,13 @@ vdp_pesi_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
INIT_OBJ(pesi_tree, PESI_TREE_MAGIC);
if ((pesi_tree->tree = WS_Alloc(req->ws, sizeof(*pesi_tree->tree)))
if ((pesi_tree->bytes_tree = WS_Alloc(req->ws, sizeof(*pesi_tree->bytes_tree)))
== NULL) {
VSLb(req->vsl, SLT_Error, "insufficient workspace for "
"parallel ESI tree data");
return (-1);
}
INIT_OBJ(pesi_tree->tree, BYTES_TREE_MAGIC);
INIT_OBJ(pesi_tree->bytes_tree, BYTES_TREE_MAGIC);
Lck_New(&pesi_tree->task_lock, lck_pesi_tree);
AZ(pthread_cond_init(&pesi_tree->task_cond, NULL));
......@@ -725,7 +725,7 @@ vdp_pesi_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
*priv = pesi;
node_fill_nodestock(req->ws, &pesi->nodestock);
pesi_tree->tree->front = pesi_tree->tree->root = root_node =
pesi_tree->bytes_tree->front = pesi_tree->bytes_tree->root = root_node =
node_alloc(pesi);
CHECK_OBJ_NOTNULL(root_node, NODE_MAGIC);
root_node->state = ST_PRIVATE;
......@@ -734,10 +734,10 @@ vdp_pesi_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
root_node->nexus.gzip.magic = NEXUS_GZIP_MAGIC;
root_node->nexus.npending_private = 1;
VSTAILQ_INIT(&root_node->nexus.children);
Lck_New(&pesi_tree->tree->tree_lock, lck_bytes_tree);
AZ(pthread_cond_init(&pesi_tree->tree->cond, NULL));
AZ(pesi_tree->tree->retval);
AZ(pesi_tree->tree->npending);
Lck_New(&pesi_tree->bytes_tree->tree_lock, lck_bytes_tree);
AZ(pthread_cond_init(&pesi_tree->bytes_tree->cond, NULL));
AZ(pesi_tree->bytes_tree->retval);
AZ(pesi_tree->bytes_tree->npending);
pesi->node = root_node;
AZ(pecx->state);
......@@ -765,7 +765,7 @@ vdp_pesi_fini(struct vdp_ctx *vdc, void **priv)
CAST_OBJ_NOTNULL(pesi, *priv, PESI_MAGIC);
pesi_tree = pesi->pesi_tree;
CHECK_OBJ_NOTNULL(pesi_tree, PESI_TREE_MAGIC);
bytes_tree = pesi_tree->tree;
bytes_tree = pesi_tree->bytes_tree;
CHECK_OBJ_NOTNULL(bytes_tree, BYTES_TREE_MAGIC);
node = pesi->node;
......@@ -821,7 +821,7 @@ vdp_pesi_fini(struct vdp_ctx *vdc, void **priv)
CHECK_OBJ_NOTNULL(pesi_tree, PESI_TREE_MAGIC);
assert(pesi_tree == pesi->pesi_tree);
CHECK_OBJ_NOTNULL(bytes_tree, BYTES_TREE_MAGIC);
assert(bytes_tree == pesi_tree->tree);
assert(bytes_tree == pesi_tree->bytes_tree);
pesi_destroy(&pesi);
task_fini(pesi_tree, pesi);
......@@ -842,7 +842,7 @@ vdp_pesi_fini(struct vdp_ctx *vdc, void **priv)
/*
* prevent race with vped_task()
*/
Lck_Lock(&pesi_tree->tree->tree_lock);
Lck_Lock(&pesi_tree->bytes_tree->tree_lock);
assert_node(bytes_tree->root, CHK_ANY);
/*
......@@ -855,7 +855,7 @@ vdp_pesi_fini(struct vdp_ctx *vdc, void **priv)
Lck_Delete(&pesi_tree->task_lock);
AZ(pthread_cond_destroy(&pesi_tree->task_cond));
Lck_Unlock(&pesi_tree->tree->tree_lock);
Lck_Unlock(&pesi_tree->bytes_tree->tree_lock);
Lck_Delete(&bytes_tree->tree_lock);
AZ(pthread_cond_destroy(&bytes_tree->cond));
......@@ -919,9 +919,9 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
CAST_OBJ_NOTNULL(pesi, *priv, PESI_MAGIC);
CHECK_OBJ_NOTNULL(pesi->pecx, PECX_MAGIC);
CHECK_OBJ_NOTNULL(pesi->pesi_tree, PESI_TREE_MAGIC);
CHECK_OBJ_NOTNULL(pesi->pesi_tree->tree, BYTES_TREE_MAGIC);
CHECK_OBJ_NOTNULL(pesi->pesi_tree->bytes_tree, BYTES_TREE_MAGIC);
pecx = pesi->pecx;
tree = pesi->pesi_tree->tree;
tree = pesi->pesi_tree->bytes_tree;
node = pesi->node;
CHECK_OBJ_NOTNULL(node, NODE_MAGIC);
......@@ -1293,8 +1293,8 @@ vped_deliver(struct req *req, struct boc *boc, int wantbody)
CAST_OBJ_NOTNULL(pesi, req->transport_priv, PESI_MAGIC);
CHECK_OBJ_NOTNULL(pesi->pesi_tree, PESI_TREE_MAGIC);
CHECK_OBJ_NOTNULL(pesi->pesi_tree->tree, BYTES_TREE_MAGIC);
tree = pesi->pesi_tree->tree;
CHECK_OBJ_NOTNULL(pesi->pesi_tree->bytes_tree, BYTES_TREE_MAGIC);
tree = pesi->pesi_tree->bytes_tree;
node = pesi->node;
parent = node->parent;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment