From 60a9991f724f76a1403c5e957f0c1a8a8633bb9c Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 18 Jan 2024 13:06:10 +0000 Subject: [PATCH] build: Ignore branches in g_clear_*() functions under lcov MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s not useful for lcov to demand branch coverage of all branches within `g_clear_*()` functions (such as `g_clear_pointer()`). By choosing to use `g_clear_*()`, the programmer explicitly doesn’t care about whether the pointer is `NULL`. The tests shouldn’t have to either. Signed-off-by: Philip Withnall --- .lcovrc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.lcovrc b/.lcovrc index 3901f81e7..9107da270 100644 --- a/.lcovrc +++ b/.lcovrc @@ -1,13 +1,16 @@ # lcov and genhtml configuration -# See http://ltp.sourceforge.net/coverage/lcov/lcovrc.5.php +# See lcovrc(5) # Always enable branch coverage lcov_branch_coverage = 1 # Exclude precondition assertions, as we can never reasonably get full branch # coverage of them, as they should never normally fail. +# Similarly exclude g_clear_*() functions (such as g_clear_object(), +# g_clear_pointer(), etc.) as it’s not useful to test both sides of the branch +# in them. # See https://github.com/linux-test-project/lcov/issues/44 -lcov_excl_br_line = LCOV_EXCL_BR_LINE|g_return_if_fail|g_return_val_if_fail|g_assert|g_assert_ +lcov_excl_br_line = LCOV_EXCL_BR_LINE|g_return_if_fail|g_return_val_if_fail|g_assert|g_assert_|g_clear_ # Similarly for unreachable assertions. lcov_excl_line = LCOV_EXCL_LINE|g_return_if_reached|g_return_val_if_reached|g_assert_not_reached \ No newline at end of file