]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
cocci: Add semantic patch to refactor dns_name_dup() usage
authorOndřej Surý <ondrej@sury.org>
Fri, 1 Nov 2019 13:30:32 +0000 (08:30 -0500)
committerOndřej Surý <ondrej@isc.org>
Fri, 29 Nov 2019 12:59:40 +0000 (13:59 +0100)
cocci/dns_name_dup.spatch [new file with mode: 0644]

diff --git a/cocci/dns_name_dup.spatch b/cocci/dns_name_dup.spatch
new file mode 100644 (file)
index 0000000..42eddce
--- /dev/null
@@ -0,0 +1,40 @@
+@@
+expression E1, E2, E3;
+statement S;
+expression V;
+@@
+
+- V = dns_name_dup(E1, E2, E3);
++ dns_name_dup(E1, E2, E3);
+- if (V != ISC_R_SUCCESS) S
+
+@@
+expression E1, E2, E3;
+statement S1, S2;
+expression V;
+@@
+
+- V = dns_name_dup(E1, E2, E3);
+- if (V != ISC_R_SUCCESS) S1 else { S2 }
++ dns_name_dup(E1, E2, E3);
++ S2
+
+@@
+expression E1, E2, E3;
+expression V;
+@@
+
+- V = dns_name_dup(E1, E2, E3);
+- RUNTIME_CHECK(V == ISC_R_SUCCESS);
++ dns_name_dup(E1, E2, E3);
+
+@@
+expression E1, E2, E3;
+statement S1, S2;
+expression V;
+@@
+
+- V = dns_name_dup(E1, E2, E3);
++ dns_name_dup(E1, E2, E3);
+S1
+- if (V != ISC_R_SUCCESS) S2