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

Suppress unused variable warning in helper_thread.c #1789

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions helper_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ static void block_signals(void)
sigset_t sigmask;

int ret;
(void)ret; // Suppress unused variable warning
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line necessary with the assert added below?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is. A more comprehensive take would be:

#if defined(NDEBUG)
#define USED_FOR_DEBUG(x) (void)0;
#else
#define USED_FOR_DEBUG(x) (void)x;
#endif

That way the warning is suppressed during debug mode, but not during opt mode.

But this seems simpler for a smaller codebase.


ret = pthread_sigmask(SIG_UNBLOCK, NULL, &sigmask);
assert(ret == 0);
ret = pthread_sigmask(SIG_BLOCK, &sigmask, NULL);
assert(ret == 0);
#endif
}

Expand Down