From: Ondřej Surý Date: Sun, 2 Feb 2020 07:00:45 +0000 (+0100) Subject: Add semantic patch to fix isc_buffer_allocate usage, it cannot fail now X-Git-Tag: v9.16.0~36^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5f682a00be868e86f588ec5d452d58f7cacaa86;p=thirdparty%2Fbind9.git Add semantic patch to fix isc_buffer_allocate usage, it cannot fail now --- diff --git a/cocci/isc_buffer_allocate_never_fail.spatch b/cocci/isc_buffer_allocate_never_fail.spatch new file mode 100644 index 00000000000..b632e4e3b9d --- /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);