diff options
author | henrike@webrtc.org <henrike@webrtc.org> | 2014-09-10 22:10:24 +0000 |
---|---|---|
committer | henrike@webrtc.org <henrike@webrtc.org> | 2014-09-10 22:10:24 +0000 |
commit | c2e6614c20710991cdbae41993e6c92d64dab9af (patch) | |
tree | 3c14147fbddab49943f4a43e3df497bae3e687d8 /base | |
parent | 2a1d25c7eb3a19e7f1fee359e75a03b5313481c9 (diff) | |
download | webrtc-c2e6614c20710991cdbae41993e6c92d64dab9af.tar.gz |
Fix MSVC warnings about value truncations, webrtc/base/ edition.
BUG=chromium:81439
TEST=none
R=henrike@webrtc.org, marpan@google.com
Review URL: https://webrtc-codereview.appspot.com/20249004
git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@7143 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'base')
-rw-r--r-- | base/httpclient.cc | 14 | ||||
-rw-r--r-- | base/httpcommon.cc | 4 | ||||
-rw-r--r-- | base/socketadapters.cc | 4 | ||||
-rw-r--r-- | base/socketadapters.h | 4 | ||||
-rw-r--r-- | base/socketaddress.cc | 6 | ||||
-rw-r--r-- | base/urlencode.cc | 12 |
6 files changed, 21 insertions, 23 deletions
diff --git a/base/httpclient.cc b/base/httpclient.cc index 62567721..0bf3880f 100644 --- a/base/httpclient.cc +++ b/base/httpclient.cc @@ -91,7 +91,7 @@ HttpCacheState HttpGetCacheState(const HttpTransaction& t) { time_t u_temp; // Current time - size_t now = time(0); + time_t now = time(0); HttpAttributeList cache_control; if (t.response.hasHeader(HH_CACHE_CONTROL, &s_temp)) { @@ -113,7 +113,7 @@ HttpCacheState HttpGetCacheState(const HttpTransaction& t) { apparent_age = response_time - date; } - size_t corrected_received_age = apparent_age; + time_t corrected_received_age = apparent_age; size_t i_temp; if (t.response.hasHeader(HH_AGE, &s_temp) && HttpStringToUInt(s_temp, (&i_temp))) { @@ -121,13 +121,13 @@ HttpCacheState HttpGetCacheState(const HttpTransaction& t) { corrected_received_age = stdmax(apparent_age, u_temp); } - size_t response_delay = response_time - request_time; - size_t corrected_initial_age = corrected_received_age + response_delay; - size_t resident_time = now - response_time; - size_t current_age = corrected_initial_age + resident_time; + time_t response_delay = response_time - request_time; + time_t corrected_initial_age = corrected_received_age + response_delay; + time_t resident_time = now - response_time; + time_t current_age = corrected_initial_age + resident_time; // Compute lifetime of document - size_t lifetime; + time_t lifetime; if (HttpHasAttribute(cache_control, "max-age", &s_temp)) { lifetime = atoi(s_temp.c_str()); } else if (t.response.hasHeader(HH_EXPIRES, &s_temp) diff --git a/base/httpcommon.cc b/base/httpcommon.cc index 569b7b3a..561d2f49 100644 --- a/base/httpcommon.cc +++ b/base/httpcommon.cc @@ -364,7 +364,7 @@ bool HttpDateToSeconds(const std::string& date, time_t* seconds) { case 'C': tval.tm_mon = 11; break; } tval.tm_year -= 1900; - size_t gmt, non_gmt = mktime(&tval); + time_t gmt, non_gmt = mktime(&tval); if ((zone[0] == '+') || (zone[0] == '-')) { if (!isdigit(zone[1]) || !isdigit(zone[2]) || !isdigit(zone[3]) || !isdigit(zone[4])) { @@ -383,7 +383,7 @@ bool HttpDateToSeconds(const std::string& date, time_t* seconds) { } // TODO: Android should support timezone, see b/2441195 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) || defined(WEBRTC_ANDROID) || defined(BSD) - tm *tm_for_timezone = localtime((time_t *)&gmt); + tm *tm_for_timezone = localtime(&gmt); *seconds = gmt + tm_for_timezone->tm_gmtoff; #else *seconds = gmt - timezone; diff --git a/base/socketadapters.cc b/base/socketadapters.cc index 1cdd1bcb..137597fd 100644 --- a/base/socketadapters.cc +++ b/base/socketadapters.cc @@ -749,7 +749,7 @@ void AsyncSocksProxyServerSocket::HandleHello(ByteBuffer* request) { } } -void AsyncSocksProxyServerSocket::SendHelloReply(int method) { +void AsyncSocksProxyServerSocket::SendHelloReply(uint8 method) { ByteBuffer response; response.WriteUInt8(5); // Socks Version response.WriteUInt8(method); // Auth method @@ -773,7 +773,7 @@ void AsyncSocksProxyServerSocket::HandleAuth(ByteBuffer* request) { state_ = SS_CONNECT; } -void AsyncSocksProxyServerSocket::SendAuthReply(int result) { +void AsyncSocksProxyServerSocket::SendAuthReply(uint8 result) { ByteBuffer response; response.WriteUInt8(1); // Negotiation Version response.WriteUInt8(result); diff --git a/base/socketadapters.h b/base/socketadapters.h index 3292df28..ddf4f18b 100644 --- a/base/socketadapters.h +++ b/base/socketadapters.h @@ -195,9 +195,9 @@ class AsyncSocksProxyServerSocket : public AsyncProxyServerSocket { void DirectSend(const ByteBuffer& buf); void HandleHello(ByteBuffer* request); - void SendHelloReply(int method); + void SendHelloReply(uint8 method); void HandleAuth(ByteBuffer* request); - void SendAuthReply(int result); + void SendAuthReply(uint8 result); void HandleConnect(ByteBuffer* request); virtual void SendConnectResult(int result, const SocketAddress& addr); diff --git a/base/socketaddress.cc b/base/socketaddress.cc index e6717e4b..b15c0c48 100644 --- a/base/socketaddress.cc +++ b/base/socketaddress.cc @@ -121,7 +121,7 @@ void SocketAddress::SetResolvedIP(const IPAddress& ip) { void SocketAddress::SetPort(int port) { ASSERT((0 <= port) && (port < 65536)); - port_ = port; + port_ = static_cast<uint16>(port); } uint32 SocketAddress::ip() const { @@ -279,9 +279,9 @@ bool SocketAddress::FromSockAddr(const sockaddr_in& saddr) { } static size_t ToSockAddrStorageHelper(sockaddr_storage* addr, - IPAddress ip, int port, int scope_id) { + IPAddress ip, uint16 port, int scope_id) { memset(addr, 0, sizeof(sockaddr_storage)); - addr->ss_family = ip.family(); + addr->ss_family = static_cast<unsigned short>(ip.family()); if (addr->ss_family == AF_INET6) { sockaddr_in6* saddr = reinterpret_cast<sockaddr_in6*>(addr); saddr->sin6_addr = ip.ipv6_address(); diff --git a/base/urlencode.cc b/base/urlencode.cc index b152829a..8dc185df 100644 --- a/base/urlencode.cc +++ b/base/urlencode.cc @@ -15,9 +15,9 @@ static int HexPairValue(const char * code) { int value = 0; - const char * pch = code; - for (;;) { - int digit = *pch++; + for (const char * pch = code; pch < code + 2; ++pch) { + value <<= 4; + int digit = *pch; if (digit >= '0' && digit <= '9') { value += digit - '0'; } @@ -30,10 +30,8 @@ static int HexPairValue(const char * code) { else { return -1; } - if (pch == code + 2) - return value; - value <<= 4; } + return value; } static int InternalUrlDecode(const char *source, char *dest, @@ -53,7 +51,7 @@ static int InternalUrlDecode(const char *source, char *dest, if (source[1] && source[2]) { int value = HexPairValue(source + 1); if (value >= 0) { - *(dest++) = value; + *(dest++) = static_cast<char>(value); source += 2; } else { |