Skip to content

Commit

Permalink
Fix some instances of -Wsign-compare
Browse files Browse the repository at this point in the history
Fix remaining instances (other than chrome/browser/ash/) as a precursor
to reenable those warnings in //third_party/shell-encryption.

Bug: 1095122
Change-Id: Ie37fc538f36308d56478115e5b388a3fcffcefc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3921580
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Reviewed-by: James Cook <jamescook@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1052332}
  • Loading branch information
hferreiro authored and Chromium LUCI CQ committed Sep 28, 2022
1 parent 231549c commit 3fce49e
Show file tree
Hide file tree
Showing 42 changed files with 142 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ TEST_F(GameFetcherTest, RegisterForUpdatesLocaleWithNoResults) {
subscription_ =
game_fetcher()->RegisterForAppUpdates(base::BindLambdaForTesting(
[&run_loop, &update_verified](const std::vector<Result>& results) {
EXPECT_EQ(results.size(), 0);
EXPECT_EQ(results.size(), 0u);
update_verified = true;
run_loop.Quit();
}));
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/apps/app_service/intent_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ apps::ConditionValuePtr ConvertArcPatternMatcherToConditionValue(
// prefixes. Detect and convert these, since prefix matching is easier &
// cheaper.
if (IsPrefixOnlyGlob(path.pattern())) {
DCHECK_GE(path.pattern().size(), 2);
DCHECK_GE(path.pattern().size(), 2u);
return std::make_unique<apps::ConditionValue>(
path.pattern().substr(0, path.pattern().size() - 2),
apps::PatternMatchType::kPrefix);
Expand Down Expand Up @@ -208,7 +208,7 @@ apps::mojom::ConditionValuePtr ConvertArcPatternMatcherToMojomConditionValue(
// prefixes. Detect and convert these, since prefix matching is easier &
// cheaper.
if (IsPrefixOnlyGlob(path.pattern())) {
DCHECK_GE(path.pattern().size(), 2);
DCHECK_GE(path.pattern().size(), 2u);
return MakeConditionValue(
path.pattern().substr(0, path.pattern().size() - 2),
apps::mojom::PatternMatchType::kPrefix);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/apps/app_service/publishers/arc_apps.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ arc::mojom::OpenUrlsRequestPtr ConstructOpenUrlsRequest(
request->action_type = GetArcActionType(intent->action);
request->activity_name = activity.Clone();
DCHECK_EQ(content_urls.size(), intent->files.size());
for (int i = 0; i < content_urls.size(); i++) {
for (size_t i = 0; i < content_urls.size(); i++) {
auto content_url = content_urls[i];
arc::mojom::ContentUrlWithMimeTypePtr url_with_type =
arc::mojom::ContentUrlWithMimeType::New();
Expand Down
18 changes: 9 additions & 9 deletions chrome/browser/apps/app_service/publishers/arc_apps_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class ArcAppsPublisherTest : public testing::Test {
});

EXPECT_EQ(source.size(), target.size());
for (int i = 0; i < static_cast<int>(source.size()); i++) {
for (size_t i = 0; i < source.size(); i++) {
EXPECT_EQ(*source[i], *target[i]);
}
}
Expand Down Expand Up @@ -416,10 +416,10 @@ TEST_F(ArcAppsPublisherTest,

ASSERT_EQ(apps::State::SUCCESS, result.value_or(apps::State::FAILED));

ASSERT_EQ(file_system_instance()->handledUrlRequests().size(), 1);
ASSERT_EQ(file_system_instance()->handledUrlRequests().size(), 1u);
auto& url_request = file_system_instance()->handledUrlRequests()[0];
ASSERT_EQ(url_request->action_type, arc::mojom::ActionType::EDIT);
ASSERT_EQ(url_request->urls.size(), 1);
ASSERT_EQ(url_request->urls.size(), 1u);
ASSERT_EQ(url_request->urls[0]->mime_type, "text/plain");
ASSERT_TRUE(
base::EndsWith(url_request->urls[0]->content_url.spec(), "test.txt"));
Expand Down Expand Up @@ -487,10 +487,10 @@ TEST_F(

ASSERT_EQ(apps::State::SUCCESS, result.value_or(apps::State::FAILED));

ASSERT_EQ(file_system_instance()->handledUrlRequests().size(), 1);
ASSERT_EQ(file_system_instance()->handledUrlRequests().size(), 1u);
auto& url_request = file_system_instance()->handledUrlRequests()[0];
ASSERT_EQ(url_request->action_type, arc::mojom::ActionType::VIEW);
ASSERT_EQ(url_request->urls.size(), 2);
ASSERT_EQ(url_request->urls.size(), 2u);
ASSERT_EQ(url_request->urls[0]->mime_type, "image/png");
ASSERT_EQ(url_request->urls[1]->mime_type, "image/jpeg");
ASSERT_TRUE(
Expand Down Expand Up @@ -526,10 +526,10 @@ TEST_F(ArcAppsPublisherTest,

ASSERT_EQ(apps::State::SUCCESS, result.value_or(apps::State::FAILED));

ASSERT_EQ(file_system_instance()->handledUrlRequests().size(), 1);
ASSERT_EQ(file_system_instance()->handledUrlRequests().size(), 1u);
auto& url_request = file_system_instance()->handledUrlRequests()[0];
ASSERT_EQ(url_request->action_type, arc::mojom::ActionType::SEND);
ASSERT_EQ(url_request->urls.size(), 1);
ASSERT_EQ(url_request->urls.size(), 1u);
ASSERT_EQ(url_request->urls[0]->mime_type, mime_type);
ASSERT_TRUE(
base::EndsWith(url_request->urls[0]->content_url.spec(), file_name));
Expand Down Expand Up @@ -558,10 +558,10 @@ TEST_F(ArcAppsPublisherTest, LaunchAppWithIntent_ShareFilesIntent_SendsExtras) {
app_id, 0, std::move(intent), apps::LaunchSource::kFromFileManager,
/*window_info=*/nullptr, base::DoNothing());

ASSERT_EQ(file_system_instance()->handledUrlRequests().size(), 1);
ASSERT_EQ(file_system_instance()->handledUrlRequests().size(), 1u);
auto& url_request = file_system_instance()->handledUrlRequests()[0];
ASSERT_EQ(url_request->action_type, arc::mojom::ActionType::SEND);
ASSERT_EQ(url_request->urls.size(), 1);
ASSERT_EQ(url_request->urls.size(), 1u);
ASSERT_EQ(url_request->extras.value()[kTestExtraKey], kTestExtraValue);
ASSERT_EQ(url_request->extras.value()["android.intent.extra.TEXT"],
kTestIntentText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ TEST_F(WebApkInstallTaskTest, SuccessfulUpdateScope) {
::testing::ElementsAre(webapk::WebApk::SCOPE_DIFFERS));

webapk::WebAppManifest manifest = last_webapk_request()->manifest();
EXPECT_EQ(last_webapk_request()->manifest().scopes_size(), 1u);
EXPECT_EQ(last_webapk_request()->manifest().scopes_size(), 1);
EXPECT_EQ(last_webapk_request()->manifest().scopes(0),
"https://www.differentexample.com/");

Expand Down
16 changes: 8 additions & 8 deletions chrome/browser/chromeos/app_mode/app_session_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ TEST_F(AppSessionTest, WebKioskTracksBrowserCreation) {
const base::Value::List* sessions_list =
dict.FindList(kKioskSessionLastDayList);
ASSERT_TRUE(sessions_list);
EXPECT_EQ(1, sessions_list->size());
EXPECT_EQ(1u, sessions_list->size());

histogram()->ExpectBucketCount(kKioskSessionStateHistogram,
KioskSessionState::kStopped, 1);
EXPECT_EQ(2, histogram()->GetAllSamples(kKioskSessionStateHistogram).size());
EXPECT_EQ(2u, histogram()->GetAllSamples(kKioskSessionStateHistogram).size());

histogram()->ExpectTotalCount(kKioskSessionDurationNormalHistogram, 1);
histogram()->ExpectTotalCount(kKioskSessionDurationInDaysNormalHistogram, 0);
Expand Down Expand Up @@ -261,14 +261,14 @@ TEST_F(AppSessionTest, ChromeAppKioskTracksBrowserCreation) {
const base::Value::List* sessions_list =
dict.FindList(kKioskSessionLastDayList);
ASSERT_TRUE(sessions_list);
EXPECT_EQ(1, sessions_list->size());
EXPECT_EQ(1u, sessions_list->size());

// Emulate exiting kiosk session.
ResetAppSession();

histogram()->ExpectBucketCount(kKioskSessionStateHistogram,
KioskSessionState::kStopped, 1);
EXPECT_EQ(2, histogram()->GetAllSamples(kKioskSessionStateHistogram).size());
EXPECT_EQ(2u, histogram()->GetAllSamples(kKioskSessionStateHistogram).size());

histogram()->ExpectTotalCount(kKioskSessionDurationNormalHistogram, 1);
histogram()->ExpectTotalCount(kKioskSessionDurationInDaysNormalHistogram, 0);
Expand Down Expand Up @@ -324,15 +324,15 @@ TEST_F(AppSessionTest, WebKioskLastDaySessions) {
ASSERT_TRUE(sessions_list);
// There should be only two kiosk sessions on the list:
// the one that happened right before the current one and the current one.
EXPECT_EQ(2, sessions_list->size());
EXPECT_EQ(2u, sessions_list->size());
for (const auto& time : *sessions_list) {
EXPECT_LE(base::Time::Now() - base::ValueToTime(time).value(),
base::Days(1));
}

histogram()->ExpectBucketCount(kKioskSessionStateHistogram,
KioskSessionState::kStopped, 1);
EXPECT_EQ(3, histogram()->GetAllSamples(kKioskSessionStateHistogram).size());
EXPECT_EQ(3u, histogram()->GetAllSamples(kKioskSessionStateHistogram).size());
histogram()->ExpectTotalCount(kKioskSessionDurationNormalHistogram, 1);
histogram()->ExpectTotalCount(kKioskSessionDurationInDaysNormalHistogram, 0);
}
Expand Down Expand Up @@ -522,7 +522,7 @@ TEST_F(AppSessionTest, OnPluginCrashed) {

histogram()->ExpectBucketCount(kKioskSessionStateHistogram,
KioskSessionState::kPluginCrashed, 1);
EXPECT_EQ(1, histogram()->GetAllSamples(kKioskSessionStateHistogram).size());
EXPECT_EQ(1u, histogram()->GetAllSamples(kKioskSessionStateHistogram).size());

histogram()->ExpectTotalCount(kKioskSessionCountPerDayHistogram, 0);
}
Expand All @@ -539,7 +539,7 @@ TEST_F(AppSessionTest, OnPluginHung) {
delegate->OnPluginHung(std::set<int>());
histogram()->ExpectBucketCount(kKioskSessionStateHistogram,
KioskSessionState::kPluginHung, 1);
EXPECT_EQ(1, histogram()->GetAllSamples(kKioskSessionStateHistogram).size());
EXPECT_EQ(1u, histogram()->GetAllSamples(kKioskSessionStateHistogram).size());

histogram()->ExpectTotalCount(kKioskSessionCountPerDayHistogram, 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionEchoPrivateApiTest, RemoveEmptyValueDicts) {

// After removing empty nested dicts, we are left with:
// {"a" : "b", "nested" : {"c" : "d"}}
EXPECT_EQ(2, dict.size());
EXPECT_EQ(1, dict.FindDict("nested")->size());
EXPECT_EQ(2u, dict.size());
EXPECT_EQ(1u, dict.FindDict("nested")->size());
EXPECT_EQ("b", *dict.FindString("a"));
EXPECT_EQ("d", *dict.FindStringByDottedPath("nested.c"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ class FileManagerEventRouterTest : public testing::Test {
// extract the "outputs" key. It then looks at the output at `index` and matches
// the `field` against the `expected_value`.
MATCHER_P3(ExpectEventArgString, index, field, expected_value, "") {
EXPECT_GE(arg.size(), 1);
EXPECT_GE(arg.size(), 1u);
const base::Value* outputs =
arg[0].FindKeyOfType("outputs", base::Value::Type::LIST);
EXPECT_TRUE(outputs) << "The outputs field is not available on the event";
EXPECT_GT((*outputs).GetList().size(), index)
EXPECT_GT(static_cast<int>((*outputs).GetList().size()), index)
<< "The supplied index on outputs is not available, size: "
<< (*outputs).GetList().size() << ", index: " << index;
const std::string* actual_value =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,7 @@ void FileManagerPrivateInternalParseTrashInfoFilesFunction::
DCHECK_EQ(parsed_data.size(), entry_definition_list->size());
std::vector<api::file_manager_private_internal::ParsedTrashInfoFile> results;

for (int i = 0; i < parsed_data.size(); ++i) {
for (size_t i = 0; i < parsed_data.size(); ++i) {
const auto& [trash_info_path, trashed_file_path, absolute_restore_path,
deletion_date] = parsed_data[i];
api::file_manager_private_internal::ParsedTrashInfoFile info;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class BaseTest : public testing::Test {
profile(), {src_url}, dest_url);
ASSERT_EQ(expect_dlp || expect_malware, !settings.empty());
if (expect_dlp || expect_malware) {
ASSERT_EQ(settings.size(), 1);
ASSERT_EQ(settings.size(), 1u);
ASSERT_TRUE(settings[0].has_value());
EXPECT_EQ(expect_dlp, settings[0].value().tags.count("dlp"));
EXPECT_EQ(expect_malware, settings[0].value().tags.count("malware"));
Expand Down Expand Up @@ -417,7 +417,7 @@ TEST_P(FileTransferAnalysisDelegateIsEnabledTest, Enabled) {
GetPrefState() == NOTHING_ENABLED_PREF) {
EXPECT_TRUE(settings.empty());
} else {
ASSERT_EQ(settings.size(), 1);
ASSERT_EQ(settings.size(), 1u);
ASSERT_TRUE(settings[0].has_value());
if (GetPrefState() == DLP_PREF || GetPrefState() == DLP_MALWARE_PREF) {
EXPECT_TRUE(settings[0].value().tags.count("dlp"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ TEST_F(SourceDestinationMatcherAshTest, NullptrSettingsNoCrash) {
size_t id = 0;
base::Value::List* settings = nullptr;
matcher.AddFilters(&id, settings);
EXPECT_EQ(id, 0);
EXPECT_EQ(id, 0u);
}

class SourceDestinationMatcherAshAddFilters
Expand Down Expand Up @@ -284,7 +284,7 @@ TEST_P(SourceDestinationMatcherAshParamTest, FromOneToAny) {
ASSERT_TRUE(settings_list);
matcher.AddFilters(&id, settings_list);
// One rule should be added!
EXPECT_EQ(id, 1);
EXPECT_EQ(id, 1u);

for (auto src_test_info : kVolumeInfos) {
bool should_match = std::string(src_test_info.fs_config_string) ==
Expand All @@ -294,7 +294,7 @@ TEST_P(SourceDestinationMatcherAshParamTest, FromOneToAny) {
matcher.Match(profile(), GetBaseFileSystemURLForVolume(src_test_info),
GetBaseFileSystemURLForVolume(dest_test_info));
if (should_match) {
ASSERT_EQ(matches.size(), 1)
ASSERT_EQ(matches.size(), 1u)
<< "matches: " << matches.size()
<< ", source: " << src_test_info.fs_config_string
<< ", destination: " << dest_test_info.fs_config_string;
Expand Down Expand Up @@ -331,7 +331,7 @@ TEST_P(SourceDestinationMatcherAshParamTest, FromAnyToOne) {
ASSERT_TRUE(settings_list);
matcher.AddFilters(&id, settings_list);
// One rule should be added!
EXPECT_EQ(id, 1);
EXPECT_EQ(id, 1u);

for (auto src_test_info : kVolumeInfos) {
for (auto dest_test_info : kVolumeInfos) {
Expand All @@ -341,7 +341,7 @@ TEST_P(SourceDestinationMatcherAshParamTest, FromAnyToOne) {
matcher.Match(profile(), GetBaseFileSystemURLForVolume(src_test_info),
GetBaseFileSystemURLForVolume(dest_test_info));
if (should_match) {
ASSERT_EQ(matches.size(), 1)
ASSERT_EQ(matches.size(), 1u)
<< "matches: " << matches.size()
<< ", source: " << src_test_info.fs_config_string
<< ", destination: " << dest_test_info.fs_config_string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ IN_PROC_BROWSER_TEST_F(AshSignalsDecoratorBrowserTest, TestNetworkSignals) {
kIpv6Address);

base::Value::List* imei_list = signals.FindList(device_signals::names::kImei);
EXPECT_EQ(imei_list->size(), 1);
EXPECT_EQ(imei_list->size(), 1u);
EXPECT_EQ(imei_list->front(), kFakeImei);

base::Value::List* meid_list = signals.FindList(device_signals::names::kMeid);
EXPECT_EQ(meid_list->size(), 1);
EXPECT_EQ(meid_list->size(), 1u);
EXPECT_EQ(meid_list->front(), kFakeMeid);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TEST_F(StartupStatusTest, TestNotVerbose) {
status_printer->PrintStage(10, "Last Stage");
status_printer->PrintSucceeded();

ASSERT_EQ(output_.size(), 5);
ASSERT_EQ(output_.size(), 5u);

// Hide cursor, init progress.
EXPECT_EQ(output_[0], "\x1b[?25l\x1b[35m[ ] ");
Expand All @@ -61,7 +61,7 @@ TEST_F(StartupStatusTest, TestVerbose) {
status_printer->PrintStage(10, "Last Stage");
status_printer->PrintSucceeded();

ASSERT_EQ(output_.size(), 6);
ASSERT_EQ(output_.size(), 6u);

// Hide cursor, init progress.
EXPECT_EQ(output_[0], "\x1b[?25l\x1b[35m[ ] ");
Expand All @@ -88,7 +88,7 @@ TEST_F(StartupStatusTest, TestError) {
status_printer->PrintStage(1, "First Stage");
status_printer->PrintError("Error message"); // Prints two things.

ASSERT_EQ(output_.size(), 4);
ASSERT_EQ(output_.size(), 4u);

// Hide cursor, init progress.
EXPECT_EQ(output_[0], "\x1b[?25l\x1b[35m[ ] ");
Expand Down
4 changes: 3 additions & 1 deletion chrome/browser/metrics/chromeos_metrics_provider_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "chrome/browser/metrics/chromeos_metrics_provider.h"

#include <stdint.h>

#include <string>

#include "ash/services/multidevice_setup/public/cpp/fake_multidevice_setup_client.h"
Expand Down Expand Up @@ -37,7 +39,7 @@ using Hardware = metrics::SystemProfileProto::Hardware;

namespace {

constexpr int kTpmFirmwareVersion = 100;
constexpr uint64_t kTpmFirmwareVersion = 100;

class FakeMultiDeviceSetupClientImplFactory
: public ash::multidevice_setup::MultiDeviceSetupClientImpl::Factory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ class NearbySharingServiceImplTestBase : public testing::Test {

// Use |feature_mask| as a bitmask to decide which features in
// |kTestFeatures| to enable or disable.
for (int i = 0; i < kTestFeatures.size(); i++) {
for (size_t i = 0; i < kTestFeatures.size(); i++) {
if (feature_mask & 1 << i) {
enabled_features.push_back(kTestFeatures[i]);
} else {
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/nearby_sharing/payload_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ void PayloadTracker::EmitFinalMetrics(
text_attachment.type(), share_target_.is_incoming, status);
}

for (int i = 0; i < share_target_.wifi_credentials_attachments.size(); ++i) {
for (size_t i = 0; i < share_target_.wifi_credentials_attachments.size();
++i) {
RecordNearbySharePayloadWifiCredentialsAttachmentTypeMetric(
share_target_.is_incoming, status);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ TEST_F(NearbyShareActionTest, CreateAttachmentFromIntentWithCustomName) {
auto attachments = NearbyShareAction::CreateAttachmentsFromIntent(
profile_, std::move(intent));

ASSERT_EQ(attachments.size(), 1);
ASSERT_EQ(attachments.size(), 1u);
ASSERT_EQ(attachments[0]->family(), Attachment::Family::kFile);

auto* file_attachment = static_cast<FileAttachment*>(attachments[0].get());
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/app_list/app_list_sort_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1348,8 +1348,8 @@ class AppListSortColorOrderBrowserTest : public AppListSortBrowserTest {
base::strings::SafeSPrintf(json_buffer, icon_json, icon_size,
icon_file_name);
char manifest_buffer[300];
size_t count = base::strings::SafeSPrintf(manifest_buffer, kManifestData,
app_name.c_str(), json_buffer);
int count = base::strings::SafeSPrintf(manifest_buffer, kManifestData,
app_name.c_str(), json_buffer);
EXPECT_EQ(count, manifest_file.Write(0, manifest_buffer, count));
manifest_file.Close();

Expand Down

0 comments on commit 3fce49e

Please sign in to comment.