From 65a45013d02286b2522b482eab44b40af79d9bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Bostr=C3=B6m?= Date: Wed, 13 Nov 2024 17:08:24 +1100 Subject: [PATCH] Replace CHECK(false) instances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In most cases NOTREACHED() is now a better option. Also performs dead-code removal. Bug: 40122554, 40580068 Change-Id: I2deffa59d375db7813ea6779b1d387718d5c62c7 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/6013409 Reviewed-by: Mark Mentovai Commit-Queue: Peter Boström --- handler/win/fastfail_test_program.cc | 3 ++- handler/win/heap_corrupting_program.cc | 3 ++- test/scoped_temp_dir_win.cc | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/handler/win/fastfail_test_program.cc b/handler/win/fastfail_test_program.cc index f654119f..5e27c50f 100644 --- a/handler/win/fastfail_test_program.cc +++ b/handler/win/fastfail_test_program.cc @@ -17,6 +17,7 @@ #include "base/check.h" #include "base/files/file_path.h" #include "base/logging.h" +#include "base/notreached.h" #include "client/crashpad_client.h" #include "util/misc/paths.h" @@ -54,7 +55,7 @@ void CfgCrash() { IndirectCall(&func); } __except (EXCEPTION_EXECUTE_HANDLER) { // CFG fast fail should never be caught. - CHECK(false); + NOTREACHED(); } // Should only reach here if CFG is disabled. abort(); diff --git a/handler/win/heap_corrupting_program.cc b/handler/win/heap_corrupting_program.cc index 8fe62f6e..7516d4a2 100644 --- a/handler/win/heap_corrupting_program.cc +++ b/handler/win/heap_corrupting_program.cc @@ -17,6 +17,7 @@ #include "base/check.h" #include "base/files/file_path.h" #include "base/logging.h" +#include "base/notreached.h" #include "client/crashpad_client.h" #include "util/misc/paths.h" @@ -43,7 +44,7 @@ void HeapCorruptionCrash() { HeapDestroy(heap); } __except (EXCEPTION_EXECUTE_HANDLER) { // Heap corruption exception should never be caught. - CHECK(false); + NOTREACHED(); } // Should never reach here. abort(); diff --git a/test/scoped_temp_dir_win.cc b/test/scoped_temp_dir_win.cc index 750a6fdf..6d23f88a 100644 --- a/test/scoped_temp_dir_win.cc +++ b/test/scoped_temp_dir_win.cc @@ -20,6 +20,7 @@ #include #include "base/check.h" +#include "base/notreached.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "gtest/gtest.h" @@ -56,7 +57,7 @@ void ScopedTempDir::Rename() { } } - CHECK(false) << "Couldn't move to a new unique temp dir"; + NOTREACHED() << "Couldn't move to a new unique temp dir"; } // static @@ -70,8 +71,7 @@ base::FilePath ScopedTempDir::CreateTemporaryDirectory() { return path_to_create; } - CHECK(false) << "Couldn't create a new unique temp dir"; - return base::FilePath(); + NOTREACHED() << "Couldn't create a new unique temp dir"; } } // namespace test