Skip to content

servers: silence -Wunused-result with pragma - #22034

Closed
vszakats wants to merge 2 commits into
curl:masterfrom
vszakats:tutilmore2
Closed

vszakats wants to merge 2 commits into
curl:masterfrom
vszakats:tutilmore2

Conversation

@vszakats

@vszakats vszakats commented Jun 15, 2026 •

Copy link
Copy Markdown
Member

In some configurations the write() functions gets the
warn_unused_result attribute, that makes casting to (void)
ineffective to silence this warning. Seen with glibc, in 5 CI jobs.
The warning option appeared in GCC 4.5 and comes enabled by default.

tests/server/util.c:329:5: error: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
  329 |     write(STDERR_FILENO, msg, sizeof(msg) - 1);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Ref: https://github.com/curl/curl/actions/runs/27548333990/job/81427544632

Refs:
#22023 (comment)
https://gcc.gnu.org/onlinedocs/gcc-16.1.0/gcc/Warning-Options.html#index-Wunused-result
https://gcc.gnu.org/onlinedocs/gcc-16.1.0/gcc/Common-Attributes.html#index-warn_005funused_005fresult
https://stackoverflow.com/questions/40576003/ignoring-warning-wunused-result

Follow-up to c8d8f08 #22023
Follow-up to e95f509 #16852

@vszakats
vszakats marked this pull request as draft June 15, 2026 19:29
@vszakats
vszakats requested a review from Copilot June 15, 2026 19:51
@vszakats
vszakats marked this pull request as ready for review June 15, 2026 19:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses build failures in tests/server/util.c caused by -Werror=unused-result when write() is declared with __attribute__((warn_unused_result)) (e.g., in some glibc configurations). It adds a targeted compiler diagnostic suppression so the signal handler can intentionally ignore write() return values without failing builds.

Changes:

  • Add GCC diagnostic push/ignored/pop pragmas to silence -Wunused-result around exit_signal_handler().
  • Replace intermediate rc bookkeeping (and the useless sink) with explicit (void)write(...) calls.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vszakats vszakats closed this in 526d3b8 Jun 15, 2026
@vszakats
vszakats deleted the tutilmore2 branch June 15, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants