diff options
author | pkasting <pkasting@chromium.org> | 2014-12-01 14:10:29 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-01 22:11:35 +0000 |
commit | 6b68a16dda00a1e2f5ffde5318ba3ea57a14e432 (patch) | |
tree | a3722acf1a8c25955704bc6035ca2e6e77933805 /net/dns | |
parent | f8abfed0a86301eef31839d090281eeea2219e86 (diff) | |
download | chromium_src-6b68a16dda00a1e2f5ffde5318ba3ea57a14e432.zip chromium_src-6b68a16dda00a1e2f5ffde5318ba3ea57a14e432.tar.gz chromium_src-6b68a16dda00a1e2f5ffde5318ba3ea57a14e432.tar.bz2 |
Fix "value possibly truncated" warnings on MSVC, net/ edition.
BUG=81439
TEST=none
Review URL: https://codereview.chromium.org/755373002
Cr-Commit-Position: refs/heads/master@{#306266}
Diffstat (limited to 'net/dns')
-rw-r--r-- | net/dns/dns_hosts.cc | 3 | ||||
-rw-r--r-- | net/dns/dns_session.cc | 12 | ||||
-rw-r--r-- | net/dns/dns_session.h | 2 | ||||
-rw-r--r-- | net/dns/dns_transaction.cc | 6 |
4 files changed, 15 insertions, 8 deletions
diff --git a/net/dns/dns_hosts.cc b/net/dns/dns_hosts.cc index 3867b44..b4d213b 100644 --- a/net/dns/dns_hosts.cc +++ b/net/dns/dns_hosts.cc @@ -195,7 +195,8 @@ bool ParseHostsFile(const base::FilePath& path, DnsHosts* dns_hosts) { if (!base::GetFileSize(path, &size)) return false; - UMA_HISTOGRAM_COUNTS("AsyncDNS.HostsSize", size); + UMA_HISTOGRAM_COUNTS("AsyncDNS.HostsSize", + static_cast<base::HistogramBase::Sample>(size)); // Reject HOSTS files larger than |kMaxHostsSize| bytes. const int64 kMaxHostsSize = 1 << 25; // 32MB diff --git a/net/dns/dns_session.cc b/net/dns/dns_session.cc index d6992f1..0b6292e 100644 --- a/net/dns/dns_session.cc +++ b/net/dns/dns_session.cc @@ -39,7 +39,9 @@ struct DnsSession::ServerStats { : last_failure_count(0), rtt_estimate(rtt_estimate_param) { rtt_histogram.reset(new base::SampleVector(buckets)); // Seed histogram with 2 samples at |rtt_estimate| timeout. - rtt_histogram->Accumulate(rtt_estimate.InMilliseconds(), 2); + rtt_histogram->Accumulate( + static_cast<base::HistogramBase::Sample>(rtt_estimate.InMilliseconds()), + 2); } // Count of consecutive failures after last success. @@ -100,7 +102,9 @@ DnsSession::~DnsSession() { RecordServerStats(); } -int DnsSession::NextQueryId() const { return rand_callback_.Run(); } +uint16 DnsSession::NextQueryId() const { + return static_cast<uint16>(rand_callback_.Run()); +} unsigned DnsSession::NextFirstServerIndex() { unsigned index = NextGoodServerIndex(server_index_); @@ -182,8 +186,8 @@ void DnsSession::RecordRTT(unsigned server_index, base::TimeDelta rtt) { deviation += (abs_error - deviation) / 4; // * delta // Histogram-based method. - server_stats_[server_index]->rtt_histogram - ->Accumulate(rtt.InMilliseconds(), 1); + server_stats_[server_index]->rtt_histogram->Accumulate( + static_cast<base::HistogramBase::Sample>(rtt.InMilliseconds()), 1); } void DnsSession::RecordLostPacket(unsigned server_index, int attempt) { diff --git a/net/dns/dns_session.h b/net/dns/dns_session.h index 01ba5e5..e878a57 100644 --- a/net/dns/dns_session.h +++ b/net/dns/dns_session.h @@ -66,7 +66,7 @@ class NET_EXPORT_PRIVATE DnsSession NetLog* net_log() const { return net_log_; } // Return the next random query ID. - int NextQueryId() const; + uint16 NextQueryId() const; // Return the index of the first configured server to use on first attempt. unsigned NextFirstServerIndex(); diff --git a/net/dns/dns_transaction.cc b/net/dns/dns_transaction.cc index 03eb7f2..beb2197 100644 --- a/net/dns/dns_transaction.cc +++ b/net/dns/dns_transaction.cc @@ -392,8 +392,10 @@ class DnsTCPAttempt : public DnsAttempt { if (rv < 0) return rv; - base::WriteBigEndian<uint16>(length_buffer_->data(), - query_->io_buffer()->size()); + uint16 query_size = static_cast<uint16>(query_->io_buffer()->size()); + if (static_cast<int>(query_size) != query_->io_buffer()->size()) + return ERR_FAILED; + base::WriteBigEndian<uint16>(length_buffer_->data(), query_size); buffer_ = new DrainableIOBuffer(length_buffer_.get(), length_buffer_->size()); next_state_ = STATE_SEND_LENGTH; |