From d5f682a00be868e86f588ec5d452d58f7cacaa86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Sun, 2 Feb 2020 08:00:45 +0100 Subject: [PATCH] Add semantic patch to fix isc_buffer_allocate usage, it cannot fail now --- cocci/isc_buffer_allocate_never_fail.spatch | 84 +++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 cocci/isc_buffer_allocate_never_fail.spatch diff --git a/cocci/isc_buffer_allocate_never_fail.spatch b/cocci/isc_buffer_allocate_never_fail.spatch new file mode 100644 index 0000000000..b632e4e3b9 --- /dev/null +++ b/cocci/isc_buffer_allocate_never_fail.spatch @@ -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);