Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcov: use no-op functions if not enabled #4376

Merged
merged 2 commits into from
Jun 28, 2021

Conversation

kmk3
Copy link
Collaborator

@kmk3 kmk3 commented Jun 27, 2021

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 b408b20 ("gcov: fix build
failure with gcc 11.1.0") / PR #4373.

[1] http:https://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

kmk3 added 2 commits June 27, 2021 13:52
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 b408b20 ("gcov: fix build
failure with gcc 11.1.0") / PR netblue30#4373.

[1] http:https://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
@kmk3 kmk3 requested review from netblue30 and smitsohu June 27, 2021 20:42
@kmk3
Copy link
Collaborator Author

kmk3 commented Jun 27, 2021

Note: There have been no other changes to gcov-related code on master recently,
so all my recent gcov PRs were made on the same branch to make it easier to see
a diff of everything (especially since some of the earlier changes are kind of
undone on the latest commit):

CLI:

git diff e770ab6d8..5106b2ec4

GitHub: https://github.com/netblue30/firejail/compare/e770ab6d8..5106b2ec4

Anyway, this is probably the last PR specific to gcov.

@netblue30 netblue30 merged commit 807bf63 into netblue30:master Jun 28, 2021
@netblue30
Copy link
Owner

all set!

@kmk3 kmk3 deleted the gcov-add-nop-functions branch June 28, 2021 00:19
kmk3 added a commit to kmk3/firejail that referenced this pull request Mar 9, 2022
Currently, the check to enable gcov relies on a non-existent macro due
to a typo, which looks like it would cause the dummy/empty versions of
the gcov functions to always be declared (even with --enable-gcov),
instead of the real ones from gcov.h.  This commit fixes the typo
(HAS_GCOV -> HAVE_GCOV).  See configure.ac for the macro declaration.

This amends commit 5106b2e ("gcov: use no-op functions if not
enabled", 2021-06-20) / PR netblue30#4376.

Occurrences of each macro with this commit applied:

    $ git grep -F HAVE_GCOV | wc -l
    16
    $ git grep -F HAS_GCOV | wc -l
    0
kmk3 added a commit that referenced this pull request Feb 15, 2023
Make it "2014-2023", which is the same as in basically every other file
that has the same Copyright author.

This kind of amends commit b408b20 ("gcov: fix build failure with gcc
11.1.0", 2021-06-15) / PR #4376.

This is a follow-up to #5664.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants