[master] fda02024b cocci: Remove redundant AN() checks after REPLACE()
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed Oct 28 13:53:11 UTC 2020
commit fda02024b2040c0d3a1807a5ab201057c63afc6a
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Wed Oct 28 14:51:13 2020 +0100
cocci: Remove redundant AN() checks after REPLACE()
Except those present in varnishtest/vtest.
diff --git a/bin/varnishd/common/common_vsmw.c b/bin/varnishd/common/common_vsmw.c
index a60efd918..8171983d1 100644
--- a/bin/varnishd/common/common_vsmw.c
+++ b/bin/varnishd/common/common_vsmw.c
@@ -246,7 +246,6 @@ vsmw_delseg(struct vsmw *vsmw, struct vsmwseg *seg)
} else {
vsmw_mkent(vsmw, vsmw->idx);
REPLACE(t, VSB_data(vsmw->vsb));
- AN(t);
fd = openat(vsmw->vdirfd,
t, O_WRONLY|O_CREAT|O_EXCL, vsmw->mode);
assert(fd >= 0);
diff --git a/bin/varnishd/mgt/mgt_symtab.c b/bin/varnishd/mgt/mgt_symtab.c
index d4666328a..530c89d17 100644
--- a/bin/varnishd/mgt/mgt_symtab.c
+++ b/bin/varnishd/mgt/mgt_symtab.c
@@ -137,7 +137,6 @@ mgt_vcl_import_vmod(struct vclprog *vp, const struct vjsn_val *vv)
ALLOC_OBJ(vf, VMODFILE_MAGIC);
AN(vf);
REPLACE(vf->fname, v_dst);
- AN(vf->fname);
VTAILQ_INIT(&vf->vcls);
AZ(mgt_vcl_cache_vmod(v_name, v_file, v_dst));
VTAILQ_INSERT_TAIL(&vmodhead, vf, list);
diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c
index 084cf4e70..520ea6dfb 100644
--- a/bin/varnishncsa/varnishncsa.c
+++ b/bin/varnishncsa/varnishncsa.c
@@ -1122,7 +1122,6 @@ main(int argc, char * const *argv)
if (format != NULL)
VUT_Error(vut, 1, "Format already set");
REPLACE(format, optarg);
- AN(format);
break;
case 'f':
if (format != NULL)
diff --git a/tools/coccinelle/replace.cocci b/tools/coccinelle/replace.cocci
index f70b7aeb8..706b28482 100644
--- a/tools/coccinelle/replace.cocci
+++ b/tools/coccinelle/replace.cocci
@@ -10,3 +10,10 @@ expression ptr, val;
- ptr = strdup(val);
- AN(ptr);
+ REPLACE(ptr, val);
+
+@@
+expression ptr, val;
+@@
+
+REPLACE(ptr, val);
+- AN(ptr);
More information about the varnish-commit
mailing list