Skip to content

"Use" fwrite result (workaround for warn_unused_result)#2187

Closed
BillyDonahue wants to merge 1 commit into
fmtlib:masterfrom
mongodb-forks:ignore_fwrite
Closed

"Use" fwrite result (workaround for warn_unused_result)#2187
BillyDonahue wants to merge 1 commit into
fmtlib:masterfrom
mongodb-forks:ignore_fwrite

Conversation

@BillyDonahue

Copy link
Copy Markdown
Contributor

Fixes #2185

@vitaut vitaut left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR

Comment thread include/fmt/format-inl.h
Comment on lines 158 to 161
// Don't use fwrite_fully because the latter may throw.
(void)std::fwrite(full_message.data(), full_message.size(), 1, stderr);
if (std::fwrite(full_message.data(), full_message.size(), 1, stderr)) {
;
}
std::fputc('\n', stderr);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we shouldn't be trying to write \n if an error occurs which will also solve the warning:

  if (std::fwrite(full_message.data(), full_message.size(), 1, stderr) > 0)
    std::fputc('\n', stderr);

@vitaut

vitaut commented Mar 31, 2021

Copy link
Copy Markdown
Contributor

Merged with a small tweak.

@vitaut vitaut closed this Mar 31, 2021
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.

(void)fwrite triggers -Wunused-result again

2 participants