Skip to content

Commit

Permalink
Fix some instances of -Wshorten-64-to-32.
Browse files Browse the repository at this point in the history
This mostly consists of replacing size_t with wtf_size_t, with a
smattering of other changes (std::string -> String, matching some types
better, inserting explicit casts, etc.).

Bug: 879657
Change-Id: I882af9c3b1c3fad67b911702826cec12c084a64e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3058404
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#907351}
  • Loading branch information
pkasting authored and Chromium LUCI CQ committed Jul 31, 2021
1 parent 671bf03 commit b4e3180
Show file tree
Hide file tree
Showing 74 changed files with 310 additions and 303 deletions.
Expand Up @@ -175,7 +175,7 @@ class ScriptStreamingTest : public testing::Test {

protected:
void AppendData(const char* data) {
uint32_t data_len = strlen(data);
uint32_t data_len = base::checked_cast<uint32_t>(strlen(data));
MojoResult result = producer_handle_->WriteData(
data, &data_len, MOJO_WRITE_DATA_FLAG_ALL_OR_NONE);
EXPECT_EQ(result, MOJO_RESULT_OK);
Expand Down
Expand Up @@ -393,7 +393,7 @@ To<Longhand>(resolved_property).{{apply_call}};
NamedGridLinesMap auto_repeat_named_grid_lines;
OrderedNamedGridLines auto_repeat_ordered_named_grid_lines;
AutoRepeatType autoRepeatType = ComputedStyleInitialValues::InitialGridAutoRepeatType();
size_t auto_repeat_insertion_point =
wtf_size_t auto_repeat_insertion_point =
ComputedStyleInitialValues::InitialGridAutoRepeatInsertionPoint();
StyleBuilderConverter::ConvertGridTrackList(
value, track_sizes, named_grid_lines, ordered_named_grid_lines,
Expand Down
Expand Up @@ -80,6 +80,7 @@
'OutlineValue',
'unsigned',
'size_t',
'wtf_size_t',
'int',
# Aligns like short
'unsigned short',
Expand Down
Expand Up @@ -50,7 +50,7 @@ class ComputedStyleInitialValues{
}

// Grid properties.
static size_t InitialGridAutoRepeatInsertionPoint() { return 0; }
static wtf_size_t InitialGridAutoRepeatInsertionPoint() { return 0; }
static AutoRepeatType InitialGridAutoRepeatType() {
return AutoRepeatType::kNoAutoRepeat;
}
Expand Down
Expand Up @@ -74,7 +74,7 @@ bool IsExtensionStableWorldId(const String& stable_world_id) {
return false;
if (stable_world_id.length() != 32)
return false;
for (size_t i = 0; i < stable_world_id.length(); ++i) {
for (unsigned i = 0; i < stable_world_id.length(); ++i) {
if (stable_world_id[i] < 'a' || stable_world_id[i] > 'p')
return false;
}
Expand Down
Expand Up @@ -15,7 +15,7 @@ namespace blink {
InterpolationValue CSSCustomListInterpolationType::MaybeConvertNeutral(
const InterpolationValue& underlying,
ConversionCheckers& conversion_checkers) const {
size_t underlying_length =
wtf_size_t underlying_length =
UnderlyingLengthChecker::GetUnderlyingLength(underlying);
conversion_checkers.push_back(
std::make_unique<UnderlyingLengthChecker>(underlying_length));
Expand Down Expand Up @@ -46,7 +46,7 @@ InterpolationValue CSSCustomListInterpolationType::MaybeConvertValue(
ConversionCheckers null_checkers;

return ListInterpolationFunctions::CreateList(
list->length(), [this, list, state, &null_checkers](size_t index) {
list->length(), [this, list, state, &null_checkers](wtf_size_t index) {
return inner_interpolation_type_->MaybeConvertValue(
list->Item(index), state, null_checkers);
});
Expand Down Expand Up @@ -77,7 +77,7 @@ const CSSValue* CSSCustomListInterpolationType::CreateCSSValue(
DCHECK(!non_interpolable_list ||
interpolable_list.length() == non_interpolable_list->length());

for (size_t i = 0; i < interpolable_list.length(); ++i) {
for (wtf_size_t i = 0; i < interpolable_list.length(); ++i) {
const NonInterpolableValue* non_interpolable_single_value =
non_interpolable_list ? non_interpolable_list->Get(i) : nullptr;
list->Append(*inner_interpolation_type_->CreateCSSValue(
Expand Down
Expand Up @@ -78,7 +78,7 @@ class TestUnderlyingValue : public UnderlyingValue {
InterpolationValue CreateInterpolableList(
const Vector<std::pair<double, int>>& values) {
return ListInterpolationFunctions::CreateList(
values.size(), [&values](size_t i) {
values.size(), [&values](wtf_size_t i) {
return InterpolationValue(
std::make_unique<InterpolableNumber>(values[i].first),
TestNonInterpolableValue::Create(values[i].second));
Expand All @@ -89,7 +89,7 @@ InterpolationValue CreateInterpolableList(
// but a non-interpolable list of nullptrs.
InterpolationValue CreateInterpolableList(const Vector<double>& values) {
return ListInterpolationFunctions::CreateList(
values.size(), [&values](size_t i) {
values.size(), [&values](wtf_size_t i) {
return InterpolationValue(
std::make_unique<InterpolableNumber>(values[i]), nullptr);
});
Expand All @@ -99,7 +99,7 @@ InterpolationValue CreateInterpolableList(const Vector<double>& values) {
// values, but an interpolable list of zeroes.
InterpolationValue CreateNonInterpolableList(const Vector<int>& values) {
return ListInterpolationFunctions::CreateList(
values.size(), [&values](size_t i) {
values.size(), [&values](wtf_size_t i) {
return InterpolationValue(std::make_unique<InterpolableNumber>(0),
TestNonInterpolableValue::Create(values[i]));
});
Expand Down
3 changes: 2 additions & 1 deletion third_party/blink/renderer/core/animation/sampled_effect.cc
Expand Up @@ -29,7 +29,8 @@ void SampledEffect::RemoveReplacedInterpolations(
[&](const auto& interpolation) {
return replaced_properties.Contains(interpolation->GetProperty());
});
interpolations_.Shrink(new_end - interpolations_.begin());
interpolations_.Shrink(
static_cast<wtf_size_t>(new_end - interpolations_.begin()));
}

void SampledEffect::UpdateReplacedProperties(
Expand Down
4 changes: 2 additions & 2 deletions third_party/blink/renderer/core/animation/scroll_timeline.cc
Expand Up @@ -288,8 +288,8 @@ bool ScrollTimeline::ScrollOffsetsEqual(
const HeapVector<Member<ScrollTimelineOffset>>& other) const {
if (scroll_offsets_.size() != other.size())
return false;
size_t size = scroll_offsets_.size();
for (size_t i = 0; i < size; ++i) {
wtf_size_t size = scroll_offsets_.size();
for (wtf_size_t i = 0; i < size; ++i) {
if (!DataEquivalent(scroll_offsets_.at(i), other.at(i)))
return false;
}
Expand Down
11 changes: 6 additions & 5 deletions third_party/blink/renderer/core/app_history/app_history.cc
Expand Up @@ -126,7 +126,7 @@ AppHistory::AppHistory(LocalDOMWindow& window)

void AppHistory::PopulateKeySet() {
DCHECK(keys_to_indices_.IsEmpty());
for (size_t i = 0; i < entries_.size(); i++)
for (wtf_size_t i = 0; i < entries_.size(); i++)
keys_to_indices_.insert(entries_[i]->key(), i);
}

Expand All @@ -138,13 +138,14 @@ void AppHistory::InitializeForNavigation(

// Construct |entries_|. Any back entries are inserted, then the current
// entry, then any forward entries.
entries_.ReserveCapacity(back_entries.size() + forward_entries.size() + 1);
entries_.ReserveCapacity(base::checked_cast<wtf_size_t>(
back_entries.size() + forward_entries.size() + 1));
for (const auto& entry : back_entries) {
entries_.emplace_back(
MakeGarbageCollected<AppHistoryEntry>(GetSupplementable(), entry));
}

current_index_ = back_entries.size();
current_index_ = base::checked_cast<wtf_size_t>(back_entries.size());
entries_.emplace_back(
MakeGarbageCollected<AppHistoryEntry>(GetSupplementable(), &current));

Expand All @@ -158,7 +159,7 @@ void AppHistory::InitializeForNavigation(
void AppHistory::CloneFromPrevious(AppHistory& previous) {
DCHECK(entries_.IsEmpty());
entries_.ReserveCapacity(previous.entries_.size());
for (size_t i = 0; i < previous.entries_.size(); i++) {
for (wtf_size_t i = 0; i < previous.entries_.size(); i++) {
// It's possible that |old_item| is indirectly holding a reference to
// the old Document. Also, it has a bunch of state we don't need for a
// non-current entry. Clone a subset of its state to a |new_item|.
Expand Down Expand Up @@ -202,7 +203,7 @@ void AppHistory::UpdateForNavigation(HistoryItem& item, WebFrameLoadType type) {
// For a new back/forward entry, truncate any forward entries and prepare to
// append.
current_index_++;
for (size_t i = current_index_; i < entries_.size(); i++)
for (wtf_size_t i = current_index_; i < entries_.size(); i++)
keys_to_indices_.erase(entries_[i]->key());
entries_.resize(current_index_ + 1);
}
Expand Down
Expand Up @@ -94,7 +94,7 @@ void ContentCaptureTaskHistogramReporter::OnAllCapturedContentSent() {
}

void ContentCaptureTaskHistogramReporter::RecordsSentContentCountPerDocument(
size_t sent_content_count) {
int sent_content_count) {
base::UmaHistogramCounts10000(kSentContentCount, sent_content_count);
}

Expand Down
Expand Up @@ -45,7 +45,7 @@ class CORE_EXPORT ContentCaptureTaskHistogramReporter
// Invoked on a capturing session ends, at that time, all captured changes
// which include the new, changed and removed content has been sent.
void OnAllCapturedContentSent();
void RecordsSentContentCountPerDocument(size_t sent_content_count);
void RecordsSentContentCountPerDocument(int sent_content_count);

private:
void MayRecordTaskRunsPerCapture();
Expand All @@ -65,7 +65,7 @@ class CORE_EXPORT ContentCaptureTaskHistogramReporter
base::TimeTicks task_scheduled_time_;
// Counts the task run times to complete a capture which includes capturing
// and sending the content.
size_t task_runs_per_capture_ = 0;
int task_runs_per_capture_ = 0;

// Records time to capture the content, its range is from 0 to 50,000
// microseconds.
Expand Down

0 comments on commit b4e3180

Please sign in to comment.