From a4f7adc756e673c3380bf65b23b8b6b57f48a8b8 Mon Sep 17 00:00:00 2001 From: brucedawson Date: Tue, 8 Mar 2016 15:58:22 -0800 Subject: Fix shift warnings from VC++ 2015 Update 2 Update 2 gives warnings when you shift an int and then assign to a 64-bit value. This behavior can lead to unintended truncation if you shift too far. These warnings existed in VC++ 2013 as well, but VC++ 2015 Update 2 issues the warnings more aggressively. Sample code that is warned about: int64_t val = 1 << retry_num; Sample fix: int64_t val = static_cast(1) << retry_num; or (if retry_num is guaranteed to be small enough): int val = 1 << retry_num; We could suppress the warnings, but I think they are good-ish warnings so I'd rather not do that. TBR=jam@chromium.org BUG=440500 Review URL: https://codereview.chromium.org/1774003002 Cr-Commit-Position: refs/heads/master@{#379984} --- google_apis/gaia/oauth2_token_service.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'google_apis/gaia') diff --git a/google_apis/gaia/oauth2_token_service.cc b/google_apis/gaia/oauth2_token_service.cc index e146ca9..def534a 100644 --- a/google_apis/gaia/oauth2_token_service.cc +++ b/google_apis/gaia/oauth2_token_service.cc @@ -313,7 +313,7 @@ void OAuth2TokenService::Fetcher::OnGetTokenFailure( int64_t OAuth2TokenService::Fetcher::ComputeExponentialBackOffMilliseconds( int retry_num) { DCHECK(retry_num < max_fetch_retry_num_); - int64_t exponential_backoff_in_seconds = 1 << retry_num; + int exponential_backoff_in_seconds = 1 << retry_num; // Returns a backoff with randomness < 1000ms return (exponential_backoff_in_seconds + base::RandDouble()) * 1000; } -- cgit v1.1