From 308510eb4fad9b112ebdd2867b0b96338b0a9a36 Mon Sep 17 00:00:00 2001 From: Billy Donahue Date: Sat, 20 Mar 2021 03:10:25 -0400 Subject: [PATCH] "Use" `fwrite` result (workaround for `warn_unused_result`) Fixes #2185 --- include/fmt/format-inl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 6722fe8c..f0bacf8b 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -155,8 +155,8 @@ FMT_FUNC void report_error(format_func func, int error_code, memory_buffer full_message; func(full_message, error_code, message); // Don't use fwrite_fully because the latter may throw. - (void)std::fwrite(full_message.data(), full_message.size(), 1, stderr); - std::fputc('\n', stderr); + if (std::fwrite(full_message.data(), full_message.size(), 1, stderr) > 0) + std::fputc('\n', stderr); } // A wrapper around fwrite that throws on error.