diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn index cd23cd7dfc..6e9f584c75 100644 --- a/modules/audio_processing/BUILD.gn +++ b/modules/audio_processing/BUILD.gn @@ -540,6 +540,7 @@ if (rtc_include_tests) { "../../rtc_base:rtc_base_approved", "../../rtc_base:rtc_json", "../../rtc_base:task_queue_for_test", + "../../rtc_base/system:file_wrapper", "../../system_wrappers", "../../test:test_support", "aec_dump", diff --git a/modules/audio_processing/test/wav_based_simulator.cc b/modules/audio_processing/test/wav_based_simulator.cc index d119f4cebf..7179fc3431 100644 --- a/modules/audio_processing/test/wav_based_simulator.cc +++ b/modules/audio_processing/test/wav_based_simulator.cc @@ -16,6 +16,7 @@ #include "modules/audio_processing/test/test_utils.h" #include "rtc_base/checks.h" +#include "rtc_base/system/file_wrapper.h" namespace webrtc { namespace test { @@ -23,13 +24,14 @@ namespace test { std::vector WavBasedSimulator::GetCustomEventChain(const std::string& filename) { std::vector call_chain; - FILE* stream = OpenFile(filename.c_str(), "r"); + FileWrapper file_wrapper = FileWrapper::OpenReadOnly(filename.c_str()); - RTC_CHECK(stream) << "Could not open the custom call order file, reverting " - "to using the default call order"; + RTC_CHECK(file_wrapper.is_open()) + << "Could not open the custom call order file, reverting " + "to using the default call order"; char c; - size_t num_read = fread(&c, sizeof(char), 1, stream); + size_t num_read = file_wrapper.Read(&c, sizeof(char)); while (num_read > 0) { switch (c) { case 'r': @@ -43,14 +45,12 @@ WavBasedSimulator::GetCustomEventChain(const std::string& filename) { default: FATAL() << "Incorrect custom call order file, reverting to using the " "default call order"; - fclose(stream); return WavBasedSimulator::GetDefaultEventChain(); } - num_read = fread(&c, sizeof(char), 1, stream); + num_read = file_wrapper.Read(&c, sizeof(char)); } - fclose(stream); return call_chain; } diff --git a/rtc_base/logging.h b/rtc_base/logging.h index 3c237df0d3..0aa1e676d1 100644 --- a/rtc_base/logging.h +++ b/rtc_base/logging.h @@ -391,6 +391,18 @@ class LogCall final { } }; +// This class is used to explicitly ignore values in the conditional +// logging macros. This avoids compiler warnings like "value computed +// is not used" and "statement has no effect". +class LogMessageVoidify { + public: + LogMessageVoidify() = default; + // This has to be an operator with a precedence lower than << but + // higher than ?: + template + void operator&(LogStreamer&& streamer) {} +}; + } // namespace webrtc_logging_impl // Direct use of this class is deprecated; please use the logging macros @@ -660,9 +672,10 @@ inline const char* AdaptString(const std::string& str) { #define RTC_DLOG_V(sev) RTC_LOG_V(sev) #define RTC_DLOG_F(sev) RTC_LOG_F(sev) #else -#define RTC_DLOG_EAT_STREAM_PARAMS() \ - while (false) \ - ::rtc::webrtc_logging_impl::LogStreamer<>() +#define RTC_DLOG_EAT_STREAM_PARAMS() \ + while (false) \ + ::rtc::webrtc_logging_impl::LogMessageVoidify() & \ + (::rtc::webrtc_logging_impl::LogStreamer<>()) #define RTC_DLOG(sev) RTC_DLOG_EAT_STREAM_PARAMS() #define RTC_DLOG_V(sev) RTC_DLOG_EAT_STREAM_PARAMS() #define RTC_DLOG_F(sev) RTC_DLOG_EAT_STREAM_PARAMS()