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:
Mirko Bonadei
2020-03-23 19:53:23 +01:00
committed by Commit Bot
parent 2028a772df
commit f1df04b094
3 changed files with 24 additions and 10 deletions

View File

@ -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::SimulationEventType>
WavBasedSimulator::GetCustomEventChain(const std::string& filename) {
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 "
"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;
}