]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add semantic patch to fix isc_buffer_allocate usage, it cannot fail now
authorOndřej Surý <ondrej@isc.org>
Sun, 2 Feb 2020 07:00:45 +0000 (08:00 +0100)
committerOndřej Surý <ondrej@isc.org>
Mon, 3 Feb 2020 07:29:00 +0000 (08:29 +0100)
cocci/isc_buffer_allocate_never_fail.spatch [new file with mode: 0644]

diff --git a/cocci/isc_buffer_allocate_never_fail.spatch b/cocci/isc_buffer_allocate_never_fail.spatch
new file mode 100644 (file)
index 0000000..b632e4e
--- /dev/null
@@ -0,0 +1,84 @@
+@@
+statement S;
+expression V;
+@@
+
+- V =
+  isc_buffer_allocate(...);
+- if (V != ISC_R_SUCCESS) S
+
+@@
+statement S1, S2;
+expression V;
+@@
+
+- V =
+  isc_buffer_allocate(...);
+- if (V == ISC_R_SUCCESS)
+  S1
+- else S2
+
+@@
+expression V;
+@@
+
+- V =
+  isc_buffer_allocate(...);
+- check_result(V, ...);
+
+@@
+@@
+
+- CHECK(
+  isc_buffer_allocate(...)
+- )
+  ;
+
+@@
+@@
+
+- DO(...,
+  isc_buffer_allocate(...)
+- )
+  ;
+
+@@
+@@
+
+- RETERR(
+  isc_buffer_allocate(...)
+- )
+  ;
+
+@@
+expression V;
+@@
+
+- V =
+  isc_buffer_allocate(...);
+- assert_int_equal(V, ISC_R_SUCCESS);
+
+@@
+expression V;
+@@
+
+- V =
+  isc_buffer_allocate(...);
+- CHECK(..., V);
+
+@@
+expression V;
+statement S;
+@@
+
+- V =
+  isc_buffer_allocate(...);
+- if (ISC_UNLIKELY(V != ISC_R_SUCCESS)) S
+
+@@
+expression V;
+@@
+
+- V =
+  isc_buffer_allocate(...);
+- RUNTIME_CHECK(V == ISC_R_SUCCESS);