]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add semantic patch for never failing isc_mempool_get()
authorOndřej Surý <ondrej@isc.org>
Wed, 24 Feb 2021 21:44:38 +0000 (22:44 +0100)
committerOndřej Surý <ondrej@sury.org>
Wed, 3 Mar 2021 14:32:01 +0000 (15:32 +0100)
The isc_mempool_get() could never fail now, thus we add a semantic patch
for cleaning up the error paths from the calls where previously we had
to check if the return value was not NULL.

cocci/isc_mempool_get_never_fail.spatch [new file with mode: 0644]

diff --git a/cocci/isc_mempool_get_never_fail.spatch b/cocci/isc_mempool_get_never_fail.spatch
new file mode 100644 (file)
index 0000000..232ff9b
--- /dev/null
@@ -0,0 +1,41 @@
+@@
+statement S;
+expression V;
+@@
+
+V = isc_mempool_get(...);
+- if (V == NULL) S
+
+@@
+type T;
+statement S;
+expression V;
+@@
+
+V = (T *)isc_mempool_get(...);
+- if (V == NULL) S
+
+@@
+statement S;
+expression V;
+@@
+
+if (V == NULL) V = isc_mempool_get(...);
+- if (V == NULL) S
+
+@@
+statement S1, S2;
+expression V;
+@@
+
+V = isc_mempool_get(...);
+- if (V == NULL) S1 else { S2 }
++ S2
+
+@@
+type T;
+expression V, E1, E2;
+@@
+
+- V = (T)isc_mempool_get(E1, E2);
++ V = isc_mempool_get(E1, E2);