Fix -Wunreachable-code on Linux.
Starting from [1] the toolchain has started to enforce -Wunreachable-code on Linux, this CL fixes the issues that are preventing the Chromium roll into WebRTC. Error example at [2]. [1] - https://chromium-review.googlesource.com/c/chromium/src/+/2093537 [2] - https://ci.chromium.org/p/webrtc/builders/try/linux_rel/34282? Bug: webrtc:11448 Change-Id: I96e8901ae80c44d69143ed8d972e250b6b926a7d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171500 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30858}
This commit is contained in:
parent
2028a772df
commit
f1df04b094
@ -540,6 +540,7 @@ if (rtc_include_tests) {
|
|||||||
"../../rtc_base:rtc_base_approved",
|
"../../rtc_base:rtc_base_approved",
|
||||||
"../../rtc_base:rtc_json",
|
"../../rtc_base:rtc_json",
|
||||||
"../../rtc_base:task_queue_for_test",
|
"../../rtc_base:task_queue_for_test",
|
||||||
|
"../../rtc_base/system:file_wrapper",
|
||||||
"../../system_wrappers",
|
"../../system_wrappers",
|
||||||
"../../test:test_support",
|
"../../test:test_support",
|
||||||
"aec_dump",
|
"aec_dump",
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "modules/audio_processing/test/test_utils.h"
|
#include "modules/audio_processing/test/test_utils.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
|
#include "rtc_base/system/file_wrapper.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -23,13 +24,14 @@ namespace test {
|
|||||||
std::vector<WavBasedSimulator::SimulationEventType>
|
std::vector<WavBasedSimulator::SimulationEventType>
|
||||||
WavBasedSimulator::GetCustomEventChain(const std::string& filename) {
|
WavBasedSimulator::GetCustomEventChain(const std::string& filename) {
|
||||||
std::vector<WavBasedSimulator::SimulationEventType> call_chain;
|
std::vector<WavBasedSimulator::SimulationEventType> 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 "
|
RTC_CHECK(file_wrapper.is_open())
|
||||||
|
<< "Could not open the custom call order file, reverting "
|
||||||
"to using the default call order";
|
"to using the default call order";
|
||||||
|
|
||||||
char c;
|
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) {
|
while (num_read > 0) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'r':
|
case 'r':
|
||||||
@ -43,14 +45,12 @@ WavBasedSimulator::GetCustomEventChain(const std::string& filename) {
|
|||||||
default:
|
default:
|
||||||
FATAL() << "Incorrect custom call order file, reverting to using the "
|
FATAL() << "Incorrect custom call order file, reverting to using the "
|
||||||
"default call order";
|
"default call order";
|
||||||
fclose(stream);
|
|
||||||
return WavBasedSimulator::GetDefaultEventChain();
|
return WavBasedSimulator::GetDefaultEventChain();
|
||||||
}
|
}
|
||||||
|
|
||||||
num_read = fread(&c, sizeof(char), 1, stream);
|
num_read = file_wrapper.Read(&c, sizeof(char));
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(stream);
|
|
||||||
return call_chain;
|
return call_chain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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 <typename... Ts>
|
||||||
|
void operator&(LogStreamer<Ts...>&& streamer) {}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace webrtc_logging_impl
|
} // namespace webrtc_logging_impl
|
||||||
|
|
||||||
// Direct use of this class is deprecated; please use the logging macros
|
// Direct use of this class is deprecated; please use the logging macros
|
||||||
@ -662,7 +674,8 @@ inline const char* AdaptString(const std::string& str) {
|
|||||||
#else
|
#else
|
||||||
#define RTC_DLOG_EAT_STREAM_PARAMS() \
|
#define RTC_DLOG_EAT_STREAM_PARAMS() \
|
||||||
while (false) \
|
while (false) \
|
||||||
::rtc::webrtc_logging_impl::LogStreamer<>()
|
::rtc::webrtc_logging_impl::LogMessageVoidify() & \
|
||||||
|
(::rtc::webrtc_logging_impl::LogStreamer<>())
|
||||||
#define RTC_DLOG(sev) RTC_DLOG_EAT_STREAM_PARAMS()
|
#define RTC_DLOG(sev) RTC_DLOG_EAT_STREAM_PARAMS()
|
||||||
#define RTC_DLOG_V(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()
|
#define RTC_DLOG_F(sev) RTC_DLOG_EAT_STREAM_PARAMS()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user