Skip to content

Explicit handle ignoring the return code for failed error messages #3045

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vmcj
Copy link
Member

@vmcj vmcj commented Aug 2, 2025

This gave a compiler warning.

@vmcj vmcj requested a review from meisterT August 4, 2025 06:20
@@ -233,7 +233,9 @@ void verbose(const char *format, ...)
void verbose_from_signalhandler(const char* msg)
{
if (!be_quiet && be_verbose) {
write(STDERR_FILENO, msg, strlen(msg));
if (write(STDERR_FILENO, msg, strlen(msg) != 0)) {
Copy link
Member

Choose a reason for hiding this comment

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

I think I would prefer just an explicit cast to (void) instead of these if's.

Copy link
Member Author

Choose a reason for hiding this comment

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

Casting to void is indeed better (TIL).

But that doesn't work because write has warn_unused_result. So we either have to do this, or wrap it in a custom function. Alternative is using a pragma but that would be even more lines.

Using the custom function would open the risk that we use it more often, and unintentionally not check the result. So I think here my current implementation is the right one (although I was not aware of that before).

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.

2 participants