[master] 7ce983ec2 more TAKE_OBJ_NOTNULLification
Nils Goroll
nils.goroll at uplex.de
Fri Jan 17 18:51:06 UTC 2020
commit 7ce983ec2e269085c97373133747268602264aa8
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Fri Jan 17 19:45:11 2020 +0100
more TAKE_OBJ_NOTNULLification
command:
spatch -I include/ -I bin/varnishd/ --dir . --in-place \
--sp-file tools/coccinelle/take_obj_notnull.cocci
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index b98d3e535..692f0961f 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -980,12 +980,8 @@ HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp, int rushmax)
struct rush rush;
unsigned r;
- AN(ocp);
- oc = *ocp;
- *ocp = NULL;
-
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
- CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+ TAKE_OBJ_NOTNULL(oc, ocp, OBJCORE_MAGIC);
assert(oc->refcnt > 0);
INIT_OBJ(&rush, RUSH_MAGIC);
diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c
index 228517d5c..40ee619b7 100644
--- a/bin/varnishd/cache/cache_vrt_vcl.c
+++ b/bin/varnishd/cache/cache_vrt_vcl.c
@@ -345,11 +345,7 @@ VRT_VCL_Allow_Cold(struct vclref **refp)
struct vcl *vcl;
struct vclref *ref;
- AN(refp);
- ref = *refp;
- *refp = NULL;
-
- CHECK_OBJ_NOTNULL(ref, VCLREF_MAGIC);
+ TAKE_OBJ_NOTNULL(ref, refp, VCLREF_MAGIC);
vcl = ref->vcl;
CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC);
@@ -398,11 +394,7 @@ VRT_VCL_Allow_Discard(struct vclref **refp)
struct vcl *vcl;
struct vclref *ref;
- AN(refp);
- ref = *refp;
- *refp = NULL;
-
- CHECK_OBJ_NOTNULL(ref, VCLREF_MAGIC);
+ TAKE_OBJ_NOTNULL(ref, refp, VCLREF_MAGIC);
vcl = ref->vcl;
CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC);
diff --git a/tools/coccinelle/take_obj_notnull.cocci b/tools/coccinelle/take_obj_notnull.cocci
index 98ac7ca93..bfb9e03cf 100644
--- a/tools/coccinelle/take_obj_notnull.cocci
+++ b/tools/coccinelle/take_obj_notnull.cocci
@@ -12,8 +12,11 @@ expression obj, objp, magic;
@@
- AN(objp);
+...
- obj = *objp;
+...
- *objp = NULL;
+...
- CHECK_OBJ_NOTNULL(obj, magic);
+ TAKE_OBJ_NOTNULL(obj, objp, magic);
@@ -22,8 +25,11 @@ expression obj, objp, magic;
@@
- AN(objp);
+...
- obj = *objp;
+...
- CHECK_OBJ_NOTNULL(obj, magic);
+...
- *objp = NULL;
+ TAKE_OBJ_NOTNULL(obj, objp, magic);
@@ -32,7 +38,9 @@ expression obj, objp, magic;
@@
- AN(objp);
+...
- obj = *objp;
+...
- CHECK_OBJ_NOTNULL(obj, magic);
+ TAKE_OBJ_NOTNULL(obj, objp, magic);
...
More information about the varnish-commit
mailing list