Skip to content

Quiet an unused result warning from g++#233

Closed
derobins wants to merge 1 commit intodevelopfrom
derobins/quiet_gcc_write_warning
Closed

Quiet an unused result warning from g++#233
derobins wants to merge 1 commit intodevelopfrom
derobins/quiet_gcc_write_warning

Conversation

@derobins
Copy link
Collaborator

No description provided.

@derobins
Copy link
Collaborator Author

derobins commented Mar 20, 2026

/home/darobins/ais/hipFile/src/amd_detail/stats.cpp: In destructor ‘hipFile::StatsServer::~StatsServer()’:
/home/darobins/ais/hipFile/src/amd_detail/stats.cpp:112:20: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  112 |         write(m_efd.get(), &i, sizeof(i));
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Copy link
Contributor

Copilot AI left a comment

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 updates the AMD stats server shutdown path to silence a g++ “unused result” warning when signaling the background thread to exit.

Changes:

  • Capture the return value of write() in StatsServer::~StatsServer() using a [[maybe_unused]] variable to quiet compiler warnings.

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

Comment on lines +111 to 115
uint64_t i{1};
[[maybe_unused]] ssize_t nbytes;

nbytes = write(m_efd.get(), &i, sizeof(i));
m_thread.join();
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

write() is used to wake the polling thread so the destructor can join(). If this write() fails (e.g., returns -1 on EINTR), the polling thread may never be notified and the destructor can block indefinitely in join(). Since you now capture the return value, it’d be safer to retry on EINTR and handle hard failures (e.g., by also making threadFn() break on POLLERR/POLLNVAL for the eventfd, or otherwise ensuring the thread is guaranteed to exit).

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@zbyrne Is this valid? Does this need a real fix?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I vote to fix it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, sounds valid. Shame we aren't using C++20 with jthreads and stop_tokens

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I'm going to close this PR then while @zbyrne implements a real fix

@derobins derobins closed this Mar 23, 2026
@derobins derobins deleted the derobins/quiet_gcc_write_warning branch March 23, 2026 19:58
zbyrne added a commit that referenced this pull request Mar 25, 2026
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.

4 participants