0

Migrate remaining NOTREACHED()s in components/

NOTREACHED() and NOTREACHED_IN_MIGRATION() are both CHECK-fatal now.
The former is [[noreturn]] so this CL also performs dead-code removal
after the NOTREACHED().

This CL does not attempt to do additional rewrites of any surrounding
code, like:

if (!foo) {
  NOTREACHED();
}

to CHECK(foo);

Those transforms take a non-trivial amount of time (and there are
thousands of instances). Cleanup can be left as an exercise for the
reader.

Bug: 40580068
Change-Id: I72205fb77747957c6bf33dbea93656fd20085a42
Low-Coverage-Reason: OTHER Should-be-unreachable code
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6010008
Reviewed-by: Rick Byers <rbyers@chromium.org>
Owners-Override: Rick Byers <rbyers@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1382618}
This commit is contained in:
Peter Boström
2024-11-13 22:26:11 +00:00
committed by Chromium LUCI CQ
parent 21b15227e9
commit 77d2135a33
444 changed files with 798 additions and 1392 deletions
components
account_id
account_manager_core
android_autofill
arc
assist_ranker
background_fetch
background_sync
blocked_content
bookmarks
browser_ui
site_settings
browsing_data
browsing_topics
captive_portal
cast
message_port
cast_streaming
cbor
cdm
chromeos_camera
cloud_devices
commerce
content_capture
content_settings
crash
cronet
desks_storage
device_event_log
device_signals
discardable_memory
dom_distiller
domain_reliability
drive
embedder_support
enterprise
error_page
favicon
favicon_base
feature_engagement
feed
find_in_page
flags_ui
gcm_driver
global_media_controls
guest_view
headless
heap_profiling
history_clusters
image_fetcher
invalidation
javascript_dialogs
keep_alive_registry
keyed_service
leveldb_proto
live_caption
local_state
lookalikes
media_message_center
memory_pressure
minidump_uploader
mirroring
nacl
named_mojo_ipc_server
navigation_interception
net_log
network_time
no_state_prefetch
ntp_tiles
offline_pages
open_from_clipboard
openscreen_platform
os_crypt
page_content_annotations
page_load_metrics
paint_preview
pdf
performance_manager
plugins
plus_addresses
policy
core
power_bookmarks
prefs
printing
privacy_sandbox
proxy_config
query_parser
reading_list
remote_cocoa
renderer_context_menu
reporting
rlz
safe_search_api
saved_tab_groups
search_engines
search_provider_logos
security_interstitials
security_state
segmentation_platform
services
sessions
shared_highlighting
sharing_message
site_engagement
site_isolation
speech
spellcheck
ssl_errors
startup_metric_utils
storage_monitor
subresource_filter
supervised_user
sync_bookmarks
sync_device_info
sync_preferences
sync_sessions
sync_user_events
system_media_controls
tab_groups
translate
trusted_vault
ui_devtools
url_formatter
url_matcher
url_pattern_index
url_rewrite
user_education
user_manager
value_store
variations
visitedlink
viz
web_package
webapps
webauthn
webcrypto
webrtc
webxr
wifi

@ -471,8 +471,7 @@ void JsonPrefStore::OnFileRead(std::unique_ptr<ReadResult> read_result) {
// can't complete synchronously, it should never be returned by the read
// operation itself.
case PREF_READ_ERROR_MAX_ENUM:
NOTREACHED_IN_MIGRATION();
break;
NOTREACHED();
}
}

@ -44,8 +44,7 @@ void PrefChangeRegistrar::Add(std::string_view path,
void PrefChangeRegistrar::Add(std::string_view path,
const NamedChangeCallback& obs) {
if (!service_) {
NOTREACHED_IN_MIGRATION();
return;
NOTREACHED();
}
DCHECK(!IsObserved(path)) << "Already had pref, \"" << path
<< "\", registered.";

@ -364,8 +364,7 @@ const base::Value* PrefService::GetUserPrefValue(std::string_view path) const {
const Preference* pref = FindPreference(path);
if (!pref) {
NOTREACHED_IN_MIGRATION() << "Trying to get an unregistered pref: " << path;
return nullptr;
NOTREACHED() << "Trying to get an unregistered pref: " << path;
}
// Look for an existing preference in the user store. If it doesn't
@ -420,9 +419,7 @@ void PrefService::ClearPref(std::string_view path) {
const Preference* pref = FindPreference(path);
if (!pref) {
NOTREACHED_IN_MIGRATION()
<< "Trying to clear an unregistered pref: " << path;
return;
NOTREACHED() << "Trying to clear an unregistered pref: " << path;
}
user_pref_store_->RemoveValue(path, GetWriteFlags(pref));
}
@ -544,8 +541,7 @@ base::Value* PrefService::GetMutableUserPref(std::string_view path,
return nullptr;
}
if (pref->GetType() != type) {
NOTREACHED_IN_MIGRATION() << "Wrong type for GetMutableValue: " << path;
return nullptr;
NOTREACHED() << "Wrong type for GetMutableValue: " << path;
}
// Look for an existing preference in the user store. Return it in case it
@ -590,10 +586,8 @@ void PrefService::SetUserPrefValue(std::string_view path,
return;
}
if (pref->GetType() != new_value.type()) {
NOTREACHED_IN_MIGRATION()
<< "Trying to set pref " << path << " of type " << pref->GetType()
<< " to value of type " << new_value.type();
return;
NOTREACHED() << "Trying to set pref " << path << " of type "
<< pref->GetType() << " to value of type " << new_value.type();
}
user_pref_store_->SetValue(path, std::move(new_value), GetWriteFlags(pref));

@ -232,8 +232,7 @@ bool PrefValueStore::PrefValueInStoreRange(
PrefValueStore::PrefStoreType first_checked_store,
PrefValueStore::PrefStoreType last_checked_store) const {
if (first_checked_store > last_checked_store) {
NOTREACHED_IN_MIGRATION();
return false;
NOTREACHED();
}
for (size_t i = first_checked_store;