diff options
author | Kelvin M. Klann <kmk3.code@protonmail.com> | 2021-06-20 18:31:12 -0300 |
---|---|---|
committer | Kelvin M. Klann <kmk3.code@protonmail.com> | 2021-06-27 15:23:22 -0300 |
commit | 5106b2ec404d4085cb4f741aeca9f2bdc95878a9 (patch) | |
tree | 599ad4edd21adc5eb9f89d1c801f21c6ec710739 /src/include | |
parent | gcov: fix indentation (diff) | |
download | firejail-5106b2ec404d4085cb4f741aeca9f2bdc95878a9.tar.gz firejail-5106b2ec404d4085cb4f741aeca9f2bdc95878a9.tar.zst firejail-5106b2ec404d4085cb4f741aeca9f2bdc95878a9.zip |
gcov: use no-op functions if not enabled
Instead of wrapping every gcov function call in an ifdef.
Note: The usage of `((void)0)` is based on section 7.2 of the C99
standard (N1256)[1] [2]:
> 7.2 Diagnostics <assert.h>
>
> 1 The header <assert.h> defines the assert macro and refers to another
> macro,
>
> NDEBUG
>
> which is not defined by <assert.h>. If NDEBUG is defined as a macro
> name at the point in the source file where <assert.h> is included, the
> assert macro is defined simply as
>
> #define assert(ignore) ((void)0)
See also assert.h(0p) from POSIX.1-2017[3].
Note: This is a continuation of commit b408b20c7 ("gcov: fix build
failure with gcc 11.1.0") / PR #4373.
[1] http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf
[2] https://port70.net/~nsz/c/c99/n1256.html#7.2
[3] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/assert.h.html
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gcov_wrapper.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/include/gcov_wrapper.h b/src/include/gcov_wrapper.h index 2f409309d..4aafb8e18 100644 --- a/src/include/gcov_wrapper.h +++ b/src/include/gcov_wrapper.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #ifndef GCOV_WRAPPER_H | 21 | #ifndef GCOV_WRAPPER_H |
22 | #define GCOV_WRAPPER_H | 22 | #define GCOV_WRAPPER_H |
23 | 23 | ||
24 | #ifdef HAS_GCOV | ||
24 | #include <gcov.h> | 25 | #include <gcov.h> |
25 | 26 | ||
26 | /* | 27 | /* |
@@ -36,5 +37,10 @@ static void __gcov_flush(void) { | |||
36 | __gcov_reset(); | 37 | __gcov_reset(); |
37 | } | 38 | } |
38 | #endif | 39 | #endif |
40 | #else | ||
41 | #define __gcov_dump() ((void)0) | ||
42 | #define __gcov_reset() ((void)0) | ||
43 | #define __gcov_flush() ((void)0) | ||
44 | #endif /* HAS_GCOV */ | ||
39 | 45 | ||
40 | #endif /* GCOV_WRAPPER_H */ | 46 | #endif /* GCOV_WRAPPER_H */ |