Skip to content

Commit

Permalink
Fix some instances of -Wshadow.
Browse files Browse the repository at this point in the history
Bug: 794619
Change-Id: I499cd08727afa717002a6f7fd3658a7d45675c96
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3100952
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Ryan Sleevi <rsleevi@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#912813}
  • Loading branch information
pkasting authored and Chromium LUCI CQ committed Aug 18, 2021
1 parent 7487508 commit d039b77
Show file tree
Hide file tree
Showing 53 changed files with 1,054 additions and 907 deletions.
4 changes: 2 additions & 2 deletions components/cronet/stale_host_resolver_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ std::unique_ptr<net::MockDnsClient> CreateHangingMockDnsClient() {
net::MockDnsClientRuleList rules;
rules.emplace_back(
kHostname, net::dns_protocol::kTypeA, false /* secure */,
net::MockDnsClientRule::Result(net::MockDnsClientRule::FAIL),
net::MockDnsClientRule::Result(net::MockDnsClientRule::ResultType::kFail),
true /* delay */);
rules.emplace_back(
kHostname, net::dns_protocol::kTypeAAAA, false /* secure */,
net::MockDnsClientRule::Result(net::MockDnsClientRule::FAIL),
net::MockDnsClientRule::Result(net::MockDnsClientRule::ResultType::kFail),
true /* delay */);

return std::make_unique<net::MockDnsClient>(config, std::move(rules));
Expand Down
8 changes: 4 additions & 4 deletions net/android/network_change_notifier_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,24 +178,24 @@ void NetworkChangeNotifierAndroid::OnMaxBandwidthChanged(

void NetworkChangeNotifierAndroid::OnNetworkConnected(NetworkHandle network) {
NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChange(
NetworkChangeType::CONNECTED, network);
NetworkChangeType::kConnected, network);
}

void NetworkChangeNotifierAndroid::OnNetworkSoonToDisconnect(
NetworkHandle network) {
NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChange(
NetworkChangeType::SOON_TO_DISCONNECT, network);
NetworkChangeType::kSoonToDisconnect, network);
}

void NetworkChangeNotifierAndroid::OnNetworkDisconnected(
NetworkHandle network) {
NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChange(
NetworkChangeType::DISCONNECTED, network);
NetworkChangeType::kDisconnected, network);
}

void NetworkChangeNotifierAndroid::OnNetworkMadeDefault(NetworkHandle network) {
NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChange(
NetworkChangeType::MADE_DEFAULT, network);
NetworkChangeType::kMadeDefault, network);
}

NetworkChangeNotifierAndroid::NetworkChangeNotifierAndroid(
Expand Down
17 changes: 9 additions & 8 deletions net/base/host_mapping_rules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,30 @@ HostMappingRules& HostMappingRules::operator=(

bool HostMappingRules::RewriteHost(HostPortPair* host_port) const {
// Check if the hostname was remapped.
for (const auto& rule : map_rules_) {
for (const auto& map_rule : map_rules_) {
// The rule's hostname_pattern will be something like:
// www.foo.com
// *.foo.com
// www.foo.com:1234
// *.foo.com:1234
// First, we'll check for a match just on hostname.
// If that fails, we'll check for a match with both hostname and port.
if (!base::MatchPattern(host_port->host(), rule.hostname_pattern)) {
if (!base::MatchPattern(host_port->host(), map_rule.hostname_pattern)) {
std::string host_port_string = host_port->ToString();
if (!base::MatchPattern(host_port_string, rule.hostname_pattern))
if (!base::MatchPattern(host_port_string, map_rule.hostname_pattern))
continue; // This rule doesn't apply.
}

// Check if the hostname was excluded.
for (const auto& rule : exclusion_rules_) {
if (base::MatchPattern(host_port->host(), rule.hostname_pattern))
for (const auto& exclusion_rule : exclusion_rules_) {
if (base::MatchPattern(host_port->host(),
exclusion_rule.hostname_pattern))
return false;
}

host_port->set_host(rule.replacement_hostname);
if (rule.replacement_port != -1)
host_port->set_port(static_cast<uint16_t>(rule.replacement_port));
host_port->set_host(map_rule.replacement_hostname);
if (map_rule.replacement_port != -1)
host_port->set_port(static_cast<uint16_t>(map_rule.replacement_port));
return true;
}

Expand Down
3 changes: 1 addition & 2 deletions net/base/ip_address_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,8 @@ TEST(IPAddressTest, IsPubliclyRoutableIPv4) {
{"224.0.0.0", RESERVED},
{"255.255.255.255", RESERVED}};

IPAddress address;
IPAddress mapped_address;
for (const auto& test : tests) {
IPAddress address;
EXPECT_TRUE(address.AssignFromIPLiteral(test.address));
ASSERT_TRUE(address.IsValid());
EXPECT_EQ(!test.is_reserved, address.IsPubliclyRoutable());
Expand Down
12 changes: 8 additions & 4 deletions net/base/ip_endpoint_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ class IPEndPointTest : public PlatformTest {
};

TEST_F(IPEndPointTest, Constructor) {
IPEndPoint endpoint;
EXPECT_EQ(0, endpoint.port());
{
IPEndPoint endpoint;
EXPECT_EQ(0, endpoint.port());
}

for (const auto& test : tests) {
IPEndPoint endpoint(test.ip_address, 80);
Expand Down Expand Up @@ -353,8 +355,10 @@ TEST_F(IPEndPointTest, LessThan) {
}

TEST_F(IPEndPointTest, ToString) {
IPEndPoint endpoint;
EXPECT_EQ(0, endpoint.port());
{
IPEndPoint endpoint;
EXPECT_EQ(0, endpoint.port());
}

uint16_t port = 100;
for (const auto& test : tests) {
Expand Down
6 changes: 3 additions & 3 deletions net/base/mock_network_change_notifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void MockNetworkChangeNotifier::NotifyNetworkMadeDefault(
void MockNetworkChangeNotifier::QueueNetworkMadeDefault(
NetworkChangeNotifier::NetworkHandle network) {
NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChange(
NetworkChangeNotifier::MADE_DEFAULT, network);
NetworkChangeNotifier::NetworkChangeType::kMadeDefault, network);
}

void MockNetworkChangeNotifier::NotifyNetworkDisconnected(
Expand All @@ -74,13 +74,13 @@ void MockNetworkChangeNotifier::NotifyNetworkDisconnected(
void MockNetworkChangeNotifier::QueueNetworkDisconnected(
NetworkChangeNotifier::NetworkHandle network) {
NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChange(
NetworkChangeNotifier::DISCONNECTED, network);
NetworkChangeNotifier::NetworkChangeType::kDisconnected, network);
}

void MockNetworkChangeNotifier::NotifyNetworkConnected(
NetworkChangeNotifier::NetworkHandle network) {
NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChange(
NetworkChangeNotifier::CONNECTED, network);
NetworkChangeNotifier::NetworkChangeType::kConnected, network);
// Spin the message loop so the notification is delivered.
base::RunLoop().RunUntilIdle();
}
Expand Down
8 changes: 4 additions & 4 deletions net/base/network_change_notifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -942,19 +942,19 @@ void NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChangeImpl(
NetworkChangeType type,
NetworkHandle network) {
switch (type) {
case CONNECTED:
case NetworkChangeType::kConnected:
network_observer_list_->Notify(
FROM_HERE, &NetworkObserver::OnNetworkConnected, network);
break;
case DISCONNECTED:
case NetworkChangeType::kDisconnected:
network_observer_list_->Notify(
FROM_HERE, &NetworkObserver::OnNetworkDisconnected, network);
break;
case SOON_TO_DISCONNECT:
case NetworkChangeType::kSoonToDisconnect:
network_observer_list_->Notify(
FROM_HERE, &NetworkObserver::OnNetworkSoonToDisconnect, network);
break;
case MADE_DEFAULT:
case NetworkChangeType::kMadeDefault:
network_observer_list_->Notify(
FROM_HERE, &NetworkObserver::OnNetworkMadeDefault, network);
break;
Expand Down
10 changes: 5 additions & 5 deletions net/base/network_change_notifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,11 @@ class NET_EXPORT NetworkChangeNotifier {
protected:
// Types of network changes specified to
// NotifyObserversOfSpecificNetworkChange.
enum NetworkChangeType {
CONNECTED,
DISCONNECTED,
SOON_TO_DISCONNECT,
MADE_DEFAULT
enum class NetworkChangeType {
kConnected,
kDisconnected,
kSoonToDisconnect,
kMadeDefault
};

// NetworkChanged signal is calculated from the IPAddressChanged and
Expand Down
1 change: 0 additions & 1 deletion net/base/network_interfaces_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ struct NET_EXPORT WlanApi {
return ERROR_SUCCESS;
}

HMODULE module;
WlanOpenHandleFunc open_handle_func;
WlanEnumInterfacesFunc enum_interfaces_func;
WlanQueryInterfaceFunc query_interface_func;
Expand Down
4 changes: 2 additions & 2 deletions net/cert/cert_verify_proc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,10 @@ base::Value CertVerifyParams(X509Certificate* cert,

if (!additional_trust_anchors.empty()) {
base::Value certs(base::Value::Type::LIST);
for (auto& cert : additional_trust_anchors) {
for (auto& anchor : additional_trust_anchors) {
std::string pem_encoded;
if (X509Certificate::GetPEMEncodedFromDER(
x509_util::CryptoBufferAsStringPiece(cert->cert_buffer()),
x509_util::CryptoBufferAsStringPiece(anchor->cert_buffer()),
&pem_encoded)) {
certs.Append(std::move(pem_encoded));
}
Expand Down
6 changes: 3 additions & 3 deletions net/cookies/cookie_monster_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3502,7 +3502,7 @@ TEST_F(CookieMonsterTest, LeaveSecureCookiesAlone_DomainMatch) {
const char* kDomain = "b.a.foo.com";
const char* kSubdomain = "c.b.a.foo.com";
// This domain does not match any, aside from the registrable domain.
const char* kOtherDomain = "z.foo.com";
const char* kAnotherDomain = "z.foo.com";

for (const char* preexisting_cookie_host :
{kRegistrableDomain, kSuperdomain, kDomain, kSubdomain}) {
Expand Down Expand Up @@ -3591,7 +3591,7 @@ TEST_F(CookieMonsterTest, LeaveSecureCookiesAlone_DomainMatch) {
// Test non-domain-matching case. These sets should all be allowed because the
// cookie is not equivalent.
GURL nonmatching_https_url(base::StrCat(
{url::kHttpsScheme, url::kStandardSchemeSeparator, kOtherDomain}));
{url::kHttpsScheme, url::kStandardSchemeSeparator, kAnotherDomain}));

for (const char* host : {kSuperdomain, kDomain, kSubdomain}) {
GURL https_url(
Expand All @@ -3605,7 +3605,7 @@ TEST_F(CookieMonsterTest, LeaveSecureCookiesAlone_DomainMatch) {
.IsInclude());
EXPECT_TRUE(CreateAndSetCookieReturnStatus(
cm.get(), nonmatching_https_url,
base::StrCat({"B=0; Secure; Domain=", kOtherDomain}))
base::StrCat({"B=0; Secure; Domain=", kAnotherDomain}))
.IsInclude());

// New cookie from insecure URL is set.
Expand Down
3 changes: 1 addition & 2 deletions net/disk_cache/blockfile/rankings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,7 @@ int Rankings::CheckListSection(List list, Addr end1, Addr end2, bool forward,
(*num_items)++;

if (next_addr == prev_addr) {
Addr last = forward ? tails_[list] : heads_[list];
if (next_addr == last)
if (next_addr == (forward ? tails_[list] : heads_[list]))
return ERR_NO_ERROR;
return ERR_INVALID_TAIL;
}
Expand Down
2 changes: 1 addition & 1 deletion net/disk_cache/entry_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,7 @@ TEST_F(DiskCacheEntryTest, MemoryOnlyEnumerationWithSparseEntries) {
++count;
disk_cache::MemEntryImpl* mem_entry =
reinterpret_cast<disk_cache::MemEntryImpl*>(entry);
EXPECT_EQ(disk_cache::MemEntryImpl::PARENT_ENTRY, mem_entry->type());
EXPECT_EQ(disk_cache::MemEntryImpl::EntryType::kParent, mem_entry->type());
mem_entry->Close();
}
EXPECT_EQ(1, count);
Expand Down
2 changes: 1 addition & 1 deletion net/disk_cache/memory/mem_backend_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void MemBackendImpl::OnEntryUpdated(MemEntryImpl* entry) {
}

void MemBackendImpl::OnEntryDoomed(MemEntryImpl* entry) {
if (entry->type() == MemEntryImpl::PARENT_ENTRY)
if (entry->type() == MemEntryImpl::EntryType::kParent)
entries_.erase(entry->key());
// LinkedList<>::RemoveFromList() removes |entry| from |lru_list_|.
entry->RemoveFromList();
Expand Down
30 changes: 15 additions & 15 deletions net/disk_cache/memory/mem_entry_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ base::Value NetLogEntryCreationParams(const MemEntryImpl* entry) {
base::Value dict(base::Value::Type::DICTIONARY);
std::string key;
switch (entry->type()) {
case MemEntryImpl::PARENT_ENTRY:
case MemEntryImpl::EntryType::kParent:
key = entry->key();
break;
case MemEntryImpl::CHILD_ENTRY:
case MemEntryImpl::EntryType::kChild:
key = GenerateChildName(entry->parent()->key(), entry->child_id());
break;
}
Expand Down Expand Up @@ -103,14 +103,14 @@ MemEntryImpl::MemEntryImpl(base::WeakPtr<MemBackendImpl> backend,

void MemEntryImpl::Open() {
// Only a parent entry can be opened.
DCHECK_EQ(PARENT_ENTRY, type());
DCHECK_EQ(EntryType::kParent, type());
CHECK_NE(ref_count_, std::numeric_limits<uint32_t>::max());
++ref_count_;
DCHECK(!doomed_);
}

bool MemEntryImpl::InUse() const {
if (type() == CHILD_ENTRY)
if (type() == EntryType::kChild)
return parent_->InUse();

return ref_count_ > 0;
Expand Down Expand Up @@ -144,7 +144,7 @@ void MemEntryImpl::Doom() {
}

void MemEntryImpl::Close() {
DCHECK_EQ(PARENT_ENTRY, type());
DCHECK_EQ(EntryType::kParent, type());
CHECK_GT(ref_count_, 0u);
--ref_count_;
if (ref_count_ == 0 && !doomed_) {
Expand All @@ -164,7 +164,7 @@ void MemEntryImpl::Close() {

std::string MemEntryImpl::GetKey() const {
// A child entry doesn't have key so this method should not be called.
DCHECK_EQ(PARENT_ENTRY, type());
DCHECK_EQ(EntryType::kParent, type());
return key_;
}

Expand Down Expand Up @@ -269,7 +269,7 @@ RangeResult MemEntryImpl::GetAvailableRange(int64_t offset,
}

bool MemEntryImpl::CouldBeSparse() const {
DCHECK_EQ(PARENT_ENTRY, type());
DCHECK_EQ(EntryType::kParent, type());
return (children_.get() != nullptr);
}

Expand Down Expand Up @@ -308,7 +308,7 @@ MemEntryImpl::~MemEntryImpl() {
if (backend_)
backend_->ModifyStorageSize(-GetStorageSize());

if (type() == PARENT_ENTRY) {
if (type() == EntryType::kParent) {
if (children_) {
EntryMap children;
children_->swap(children);
Expand All @@ -328,7 +328,7 @@ MemEntryImpl::~MemEntryImpl() {

int MemEntryImpl::InternalReadData(int index, int offset, IOBuffer* buf,
int buf_len) {
DCHECK(type() == PARENT_ENTRY || index == kSparseData);
DCHECK(type() == EntryType::kParent || index == kSparseData);

if (index < 0 || index >= kNumStreams || buf_len < 0)
return net::ERR_INVALID_ARGUMENT;
Expand All @@ -350,7 +350,7 @@ int MemEntryImpl::InternalReadData(int index, int offset, IOBuffer* buf,

int MemEntryImpl::InternalWriteData(int index, int offset, IOBuffer* buf,
int buf_len, bool truncate) {
DCHECK(type() == PARENT_ENTRY || index == kSparseData);
DCHECK(type() == EntryType::kParent || index == kSparseData);
if (!backend_)
return net::ERR_INSUFFICIENT_RESOURCES;

Expand Down Expand Up @@ -399,7 +399,7 @@ int MemEntryImpl::InternalWriteData(int index, int offset, IOBuffer* buf,
int MemEntryImpl::InternalReadSparseData(int64_t offset,
IOBuffer* buf,
int buf_len) {
DCHECK_EQ(PARENT_ENTRY, type());
DCHECK_EQ(EntryType::kParent, type());

if (!InitSparseInfo())
return net::ERR_CACHE_OPERATION_NOT_SUPPORTED;
Expand Down Expand Up @@ -463,7 +463,7 @@ int MemEntryImpl::InternalReadSparseData(int64_t offset,
int MemEntryImpl::InternalWriteSparseData(int64_t offset,
IOBuffer* buf,
int buf_len) {
DCHECK_EQ(PARENT_ENTRY, type());
DCHECK_EQ(EntryType::kParent, type());

if (!InitSparseInfo())
return net::ERR_CACHE_OPERATION_NOT_SUPPORTED;
Expand Down Expand Up @@ -533,7 +533,7 @@ int MemEntryImpl::InternalWriteSparseData(int64_t offset,
}

RangeResult MemEntryImpl::InternalGetAvailableRange(int64_t offset, int len) {
DCHECK_EQ(PARENT_ENTRY, type());
DCHECK_EQ(EntryType::kParent, type());

if (!InitSparseInfo())
return RangeResult(net::ERR_CACHE_OPERATION_NOT_SUPPORTED);
Expand Down Expand Up @@ -580,7 +580,7 @@ RangeResult MemEntryImpl::InternalGetAvailableRange(int64_t offset, int len) {
}

bool MemEntryImpl::InitSparseInfo() {
DCHECK_EQ(PARENT_ENTRY, type());
DCHECK_EQ(EntryType::kParent, type());

if (!children_) {
// If we already have some data in sparse stream but we are being
Expand All @@ -597,7 +597,7 @@ bool MemEntryImpl::InitSparseInfo() {
}

MemEntryImpl* MemEntryImpl::GetChild(int64_t offset, bool create) {
DCHECK_EQ(PARENT_ENTRY, type());
DCHECK_EQ(EntryType::kParent, type());
int64_t index = ToChildIndex(offset);
auto i = children_->find(index);
if (i != children_->end())
Expand Down
Loading

0 comments on commit d039b77

Please sign in to comment.