Skip to content

Commit

Permalink
Fix a few -Wunreachable-code-aggressive warnings
Browse files Browse the repository at this point in the history
No behavior change.

Bug: 1066980
Change-Id: Ic1c2816140668d4fc0e239abe1dcc7b2676e2280
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3054494
Auto-Submit: Nico Weber <thakis@chromium.org>
Owners-Override: Nico Weber <thakis@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#905767}
  • Loading branch information
nico committed Jul 27, 2021
1 parent f6fc6d8 commit b487a83
Show file tree
Hide file tree
Showing 52 changed files with 100 additions and 117 deletions.
3 changes: 2 additions & 1 deletion base/allocator/partition_allocator/starscan/stack/stack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ void* GetStackTop() {
// the start of the stack.
// See https://code.google.com/p/nativeclient/issues/detail?id=3431.
return __libc_stack_end;
#endif // defined(LIBC_GLIBC)
#else
return nullptr;
#endif // defined(LIBC_GLIBC)
}

#else // defined(OS_WIN)
Expand Down
1 change: 0 additions & 1 deletion base/android/library_loader/library_prefetcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ PrefetchStatus ForkAndPrefetch(bool ordered_only) {
case SIGSEGV:
case SIGBUS:
return PrefetchStatus::kChildProcessCrashed;
break;
case SIGKILL:
case SIGTERM:
default:
Expand Down
14 changes: 7 additions & 7 deletions base/debug/stack_trace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,22 @@ uintptr_t GetStackEnd() {
main_stack_end = stack_end;
}
return stack_end; // 0 in case of error
#elif defined(OS_APPLE)
// No easy way to get end of the stack for non-main threads,
// see crbug.com/617730.
return reinterpret_cast<uintptr_t>(pthread_get_stackaddr_np(pthread_self()));
#else

#elif (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(__GLIBC__)

#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(__GLIBC__)
if (GetCurrentProcId() == PlatformThread::CurrentId()) {
// For the main thread we have a shortcut.
return reinterpret_cast<uintptr_t>(__libc_stack_end);
}

// No easy way to get end of the stack for non-main threads,
// see crbug.com/617730.
#elif defined(OS_APPLE)
return reinterpret_cast<uintptr_t>(pthread_get_stackaddr_np(pthread_self()));
#endif

// Don't know how to get end of the stack.
return 0;
#endif
}
#endif // BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS)

Expand Down
18 changes: 8 additions & 10 deletions base/files/file_path_watcher_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@

#include "base/files/file_path_watcher.h"

#if defined(OS_WIN)
#include <windows.h>
#include <aclapi.h>
#elif defined(OS_POSIX)
#include <sys/stat.h>
#endif

#include <memory>
#include <set>
#include <string>
Expand All @@ -37,6 +30,13 @@
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"

#if defined(OS_WIN)
#include <windows.h>
#include <aclapi.h>
#elif defined(OS_POSIX)
#include <sys/stat.h>
#endif

#if defined(OS_ANDROID)
#include "base/android/path_utils.h"
#endif // defined(OS_ANDROID)
Expand Down Expand Up @@ -833,10 +833,8 @@ TEST_F(FilePathWatcherTest, LinkedDirectoryPart3) {
// `g_inotify_reader` due to a race in recursive watch.
// See https://crbug.com/990004.
TEST_F(FilePathWatcherTest, RacyRecursiveWatch) {
if (!FilePathWatcher::RecursiveWatchAvailable()) {
if (!FilePathWatcher::RecursiveWatchAvailable())
GTEST_SKIP();
return;
}

FilePath dir(temp_dir_.GetPath().AppendASCII("dir"));

Expand Down
2 changes: 0 additions & 2 deletions base/profiler/suspendable_thread_delegate_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ bool GetThreadContextImpl(thread_act_t target_thread, RegisterContext* state) {
return thread_get_state(target_thread, kThreadStateFlavor,
reinterpret_cast<thread_state_t>(state),
&count) == KERN_SUCCESS;

return false;
}

} // namespace
Expand Down
3 changes: 2 additions & 1 deletion base/trace_event/thread_instruction_count.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ bool ThreadInstructionCount::IsSupported() {
return false;

return true;
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
#else
return false;
#endif
}

ThreadInstructionCount ThreadInstructionCount::Now() {
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/app_controller_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1998,7 +1998,6 @@ - (void)cancelWebAuthenticationSessionRequest:
FALLTHROUGH;
case Profile::CREATE_STATUS_LOCAL_FAIL:
return nullptr;
break;
}
AppController* controller =
base::mac::ObjCCastStrict<AppController>([NSApp delegate]);
Expand Down
4 changes: 3 additions & 1 deletion chrome/browser/ssl/ssl_browsertest_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,13 @@ void SecurityStateWebContentsObserver::DidChangeVisibleSecurityState() {
bool UsingBuiltinCertVerifier() {
#if defined(OS_FUCHSIA) || defined(OS_LINUX) || defined(OS_CHROMEOS)
return true;
#elif BUILDFLAG(BUILTIN_CERT_VERIFIER_FEATURE_SUPPORTED)
#else
#if BUILDFLAG(BUILTIN_CERT_VERIFIER_FEATURE_SUPPORTED)
if (base::FeatureList::IsEnabled(net::features::kCertVerifierBuiltinFeature))
return true;
#endif
return false;
#endif
}

bool SystemSupportsHardFailRevocationChecking() {
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/ui/browser_view_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ bool GetCustomFramePrefDefault() {
#endif // defined(USE_OZONE)
#if defined(USE_X11)
return ui::GetCustomFramePrefDefault();
#endif // defined(USE_X11)
#else
return false;
#endif // defined(USE_X11)
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ std::unique_ptr<views::LinuxUI> BuildLinuxUI() {
// GtkUi is the only LinuxUI implementation for now.
#if BUILDFLAG(USE_GTK)
return BuildGtkUi();
#endif
#else
return nullptr;
#endif
}

} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ std::unique_ptr<OpaqueBrowserFrameView> CreateOpaqueBrowserFrameView(
}
return std::make_unique<BrowserFrameViewLinux>(
frame, browser_view, new BrowserFrameViewLayoutLinux());
#endif
#else
return std::make_unique<OpaqueBrowserFrameView>(
frame, browser_view, new OpaqueBrowserFrameViewLayout());
#endif
}

} // namespace
Expand Down
1 change: 0 additions & 1 deletion chrome/common/chrome_paths.cc
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ bool PathProvider(int key, base::FilePath* result) {
cur = base::mac::FrameworkBundlePath();
cur = cur.Append(FILE_PATH_LITERAL("Resources"))
.Append(FILE_PATH_LITERAL("resources.pak"));
break;
#elif defined(OS_ANDROID)
if (!base::PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &cur))
return false;
Expand Down
3 changes: 2 additions & 1 deletion chrome/test/base/dialog_test_browser_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ gfx::Size DialogTestBrowserWindow::GetMaximumDialogSize() {
#if defined(OS_MAC)
// Zero-size windows aren't allowed on Mac.
return gfx::Size(1, 1);
#endif
#else
return gfx::Size();
#endif
}

void DialogTestBrowserWindow::AddObserver(ModalDialogHostObserver* observer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,9 @@ bool CardUnmaskPromptControllerImpl::ShouldDismissUnmaskPromptUponResult(
// instead show a different error dialog.
return result == AutofillClient::VCN_RETRIEVAL_PERMANENT_FAILURE ||
result == AutofillClient::VCN_RETRIEVAL_TRY_AGAIN_FAILURE;
#endif // OS_ANDROID
#else
return false;
#endif // OS_ANDROID
}

void CardUnmaskPromptControllerImpl::LogOnCloseEvents() {
Expand Down
3 changes: 2 additions & 1 deletion components/dbus/menu/menu_property_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ std::string ToDBusKeySym(ui::KeyboardCode code) {
return base::UTF16ToUTF8(
std::u16string(1, ui::GetUnicodeCharacterFromXKeySym(
XKeysymForWindowsKeyCode(code, false))));
#endif
#else
return {};
#endif
}

std::vector<DbusString> GetDbusMenuShortcut(ui::Accelerator accelerator) {
Expand Down
3 changes: 2 additions & 1 deletion components/metrics/version_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ SystemProfileProto::Channel AsProtobufChannel(version_info::Channel channel) {
std::string GetAppPackageName() {
#if defined(OS_ANDROID)
return base::android::BuildInfo::GetInstance()->package_name();
#endif
#else
return std::string();
#endif
}

} // namespace metrics
1 change: 0 additions & 1 deletion components/page_info/page_info_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ std::u16string PageInfoUI::PermissionStateToUIString(
break;
case CONTENT_SETTING_ASK:
return GetPermissionAskStateString(permission.type);
break;
default:
NOTREACHED();
}
Expand Down
9 changes: 3 additions & 6 deletions components/policy/core/common/policy_loader_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,10 @@ bool ShouldHonorPolicies() {
base::MacDeviceManagementStateNew::kLimitedMDMEnrollment ||
mdm_state == base::MacDeviceManagementStateNew::kFullMDMEnrollment ||
mdm_state == base::MacDeviceManagementStateNew::kDEPMDMEnrollment;
} else {
base::MacDeviceManagementStateOld mdm_state =
base::IsDeviceRegisteredWithManagementOld();
return mdm_state == base::MacDeviceManagementStateOld::kMDMEnrollment;
}

return false;
base::MacDeviceManagementStateOld mdm_state =
base::IsDeviceRegisteredWithManagementOld();
return mdm_state == base::MacDeviceManagementStateOld::kMDMEnrollment;
}

} // namespace
Expand Down
1 change: 0 additions & 1 deletion components/remote_cocoa/browser/scoped_cg_window_id.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ base::WeakPtr<ScopedCGWindowID> ScopedCGWindowID::Get(uint32_t cg_window_id) {
DCHECK_CALLED_ON_VALID_THREAD(found->second->thread_checker_);

return found->second->weak_factory_.GetWeakPtr();
return nullptr;
}

} // namespace remote_cocoa
4 changes: 0 additions & 4 deletions components/segmentation_platform/internal/stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ AdaptiveToolbarSegmentSwitch GetSegmentSwitch(
NOTREACHED();
return AdaptiveToolbarSegmentSwitch::kUnknown;
}
break;

case OptimizationTarget::OPTIMIZATION_TARGET_SEGMENTATION_NEW_TAB:
switch (new_selection) {
Expand All @@ -83,7 +82,6 @@ AdaptiveToolbarSegmentSwitch GetSegmentSwitch(
NOTREACHED();
return AdaptiveToolbarSegmentSwitch::kUnknown;
}
break;

case OptimizationTarget::OPTIMIZATION_TARGET_SEGMENTATION_SHARE:
switch (new_selection) {
Expand All @@ -97,7 +95,6 @@ AdaptiveToolbarSegmentSwitch GetSegmentSwitch(
NOTREACHED();
return AdaptiveToolbarSegmentSwitch::kUnknown;
}
break;

case OptimizationTarget::OPTIMIZATION_TARGET_SEGMENTATION_VOICE:
switch (new_selection) {
Expand All @@ -111,7 +108,6 @@ AdaptiveToolbarSegmentSwitch GetSegmentSwitch(
NOTREACHED();
return AdaptiveToolbarSegmentSwitch::kUnknown;
}
break;

default:
NOTREACHED();
Expand Down
3 changes: 2 additions & 1 deletion components/translate/core/browser/translate_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,9 @@ bool TranslatePrefs::IsDetailedLanguageSettingsEnabled() {
#elif defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX)
return base::FeatureList::IsEnabled(
language::kDesktopDetailedLanguageSettings);
#endif
#else
return false;
#endif
}

bool TranslatePrefs::ShouldAutoTranslate(base::StringPiece source_language,
Expand Down
8 changes: 4 additions & 4 deletions components/viz/common/display/de_jelly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ bool DeJellyActive() {

#if defined(OS_ANDROID)
return Java_DeJellyUtils_useDeJelly(base::android::AttachCurrentThread());
#endif

#else
return true;
#endif
}

float DeJellyScreenWidth() {
Expand All @@ -46,9 +46,9 @@ float DeJellyScreenWidth() {

#if defined(OS_ANDROID)
return Java_DeJellyUtils_screenWidth(base::android::AttachCurrentThread());
#endif

#else
return 1440.0f;
#endif
}

float MaxDeJellyHeight() {
Expand Down
3 changes: 2 additions & 1 deletion components/viz/common/viz_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ namespace viz {
bool PreferRGB565ResourcesForDisplay() {
#if defined(OS_ANDROID)
return base::SysInfo::AmountOfPhysicalMemoryMB() <= 512;
#endif
#else
return false;
#endif
}

#if defined(OS_ANDROID)
Expand Down
3 changes: 2 additions & 1 deletion components/viz/host/host_gpu_memory_buffer_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ bool WillGetGmbConfigFromGpu() {
// non-Ozone/X11 must always get native configs on gpu.
DCHECK(!features::IsUsingOzonePlatform());
return true;
#endif
#else
return false;
#endif
}

} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ bool MustSignalGmbConfigReadyForTest() {
// X11 requires GPU process initialization to determine GMB support.
DCHECK(!features::IsUsingOzonePlatform());
return true;
#endif
#else
return false;
#endif
}

class TestGpuService : public mojom::GpuService {
Expand Down
3 changes: 2 additions & 1 deletion content/browser/gpu/gpu_data_manager_impl_private.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ bool CanUpdateGmbGpuPreferences() {
#if defined(USE_X11)
DCHECK(!features::IsUsingOzonePlatform());
return false;
#endif
#else
return true;
#endif
}

#if defined(OS_ANDROID)
Expand Down
4 changes: 2 additions & 2 deletions content/browser/gpu/gpu_memory_buffer_manager_singleton.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() {

#if defined(OS_MAC)
return ui::WindowResizeHelperMac::Get()->task_runner();
#endif

#else
return GetUIThreadTaskRunner({});
#endif
}

} // namespace
Expand Down
3 changes: 0 additions & 3 deletions content/child/child_thread_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,11 @@ mojo::IncomingInvitation InitializeMojoIPCChannel() {
if (!client) {
LOG(ERROR) << "Mach rendezvous failed, terminating process (parent died?)";
base::Process::TerminateCurrentProcessImmediately(0);
return {};
}
auto receive = client->TakeReceiveRight('mojo');
if (!receive.is_valid()) {
LOG(ERROR) << "Invalid PlatformChannel receive right";
base::Process::TerminateCurrentProcessImmediately(0);
return {};
}
endpoint =
mojo::PlatformChannelEndpoint(mojo::PlatformHandle(std::move(receive)));
Expand Down Expand Up @@ -585,7 +583,6 @@ void ChildThreadImpl::Init(const Options& options) {
if (!invitation.is_valid()) {
LOG(ERROR) << "Child process could not find its Mojo invitation";
base::Process::TerminateCurrentProcessImmediately(0);
return;
}
child_process_pipe_for_receiver =
invitation.ExtractMessagePipe(kChildProcessReceiverAttachmentName);
Expand Down
Loading

0 comments on commit b487a83

Please sign in to comment.