summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-20 06:53:28 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-20 06:53:28 +0000
commit34b2b007db875a6acb853c5cd2a247fbb32c0f88 (patch)
tree6dc39bc9f10d6e8eedcdf14821ba9e96b5ccab51 /net
parent24b857793e27aded8d804a112a5fe6c77e28b081 (diff)
downloadchromium_src-34b2b007db875a6acb853c5cd2a247fbb32c0f88.zip
chromium_src-34b2b007db875a6acb853c5cd2a247fbb32c0f88.tar.gz
chromium_src-34b2b007db875a6acb853c5cd2a247fbb32c0f88.tar.bz2
Add compiler-specific "examine printf format" attributes to printfs.
Functions that take a printf-style format get a new annotation, which produces a bunch of compiler warnings when you use printf impoperly. This change adds the annotations and fixes the warnings. We now must use PRId64 for 64-bit numbers and the PRIsz for size_t. Review URL: http://codereview.chromium.org/339059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32600 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/cookie_monster.cc4
-rw-r--r--net/base/host_cache_unittest.cc3
-rw-r--r--net/base/load_log_util.cc3
-rw-r--r--net/base/net_util_unittest.cc20
-rw-r--r--net/disk_cache/sparse_control.cc5
-rw-r--r--net/ftp/ftp_directory_listing_buffer_unittest.cc3
-rw-r--r--net/ftp/ftp_directory_listing_parsers_unittest.cc9
-rw-r--r--net/http/http_cache.cc7
-rw-r--r--net/http/http_network_transaction.cc3
-rw-r--r--net/http/partial_data.cc16
-rw-r--r--net/proxy/proxy_config_service_linux_unittest.cc15
-rw-r--r--net/proxy/proxy_service_unittest.cc6
-rw-r--r--net/url_request/request_tracker_unittest.cc5
-rw-r--r--net/url_request/url_request_unittest.cc9
-rw-r--r--net/url_request/url_request_view_net_internals_job.cc7
15 files changed, 68 insertions, 47 deletions
diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc
index 01b68a1..2af8a72 100644
--- a/net/base/cookie_monster.cc
+++ b/net/base/cookie_monster.cc
@@ -1172,9 +1172,9 @@ bool CookieMonster::CanonicalCookie::IsOnPath(
}
std::string CookieMonster::CanonicalCookie::DebugString() const {
- return StringPrintf("name: %s value: %s path: %s creation: %llu",
+ return StringPrintf("name: %s value: %s path: %s creation: %" PRId64,
name_.c_str(), value_.c_str(), path_.c_str(),
- creation_date_.ToTimeT());
+ static_cast<int64>(creation_date_.ToTimeT()));
}
} // namespace
diff --git a/net/base/host_cache_unittest.cc b/net/base/host_cache_unittest.cc
index a879bed..b51b2e0 100644
--- a/net/base/host_cache_unittest.cc
+++ b/net/base/host_cache_unittest.cc
@@ -4,6 +4,7 @@
#include "net/base/host_cache.h"
+#include "base/format_macros.h"
#include "base/stl_util-inl.h"
#include "base/string_util.h"
#include "net/base/net_errors.h"
@@ -302,7 +303,7 @@ TEST(HostCacheTest, KeyComparators) {
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
- SCOPED_TRACE(StringPrintf("Test[%d]", i));
+ SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]", i));
const HostCache::Key& key1 = tests[i].key1;
const HostCache::Key& key2 = tests[i].key2;
diff --git a/net/base/load_log_util.cc b/net/base/load_log_util.cc
index df31218..3905f4a 100644
--- a/net/base/load_log_util.cc
+++ b/net/base/load_log_util.cc
@@ -4,6 +4,7 @@
#include "net/base/load_log_util.h"
+#include "base/format_macros.h"
#include "base/string_util.h"
namespace net {
@@ -31,7 +32,7 @@ class FormatHelper {
for (size_t i = 0; i < entries_.size(); ++i) {
if (log->num_entries_truncated() > 0 && i + 1 == entries_.size()) {
- result += StringPrintf(" ... Truncated %d entries ...\n",
+ result += StringPrintf(" ... Truncated %" PRIuS " entries ...\n",
log->num_entries_truncated());
}
diff --git a/net/base/net_util_unittest.cc b/net/base/net_util_unittest.cc
index 308ef80..1057402 100644
--- a/net/base/net_util_unittest.cc
+++ b/net/base/net_util_unittest.cc
@@ -2,15 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/basictypes.h"
-#include "base/file_path.h"
-#include "base/string_util.h"
-#include "base/sys_string_conversions.h"
-#include "base/time.h"
-#include "googleurl/src/gurl.h"
-#include "net/base/escape.h"
#include "net/base/net_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_WIN)
#include <ws2tcpip.h>
@@ -18,6 +10,14 @@
#include <netdb.h>
#endif
+#include "base/file_path.h"
+#include "base/format_macros.h"
+#include "base/string_util.h"
+#include "base/sys_string_conversions.h"
+#include "base/time.h"
+#include "googleurl/src/gurl.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
namespace {
class NetUtilTest : public testing::Test {
@@ -579,7 +579,7 @@ TEST(NetUtilTest, GetIdentityFromURL) {
},
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
- SCOPED_TRACE(StringPrintf("Test[%d]: %s", i, tests[i].input_url));
+ SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, tests[i].input_url));
GURL url(tests[i].input_url);
std::wstring username, password;
@@ -1587,7 +1587,7 @@ TEST(NetUtilTest, SimplifyUrlForRequest) {
},
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
- SCOPED_TRACE(StringPrintf("Test[%d]: %s", i, tests[i].input_url));
+ SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, tests[i].input_url));
GURL input_url(GURL(tests[i].input_url));
GURL expected_url(GURL(tests[i].expected_simplified_url));
EXPECT_EQ(expected_url, net::SimplifyUrlForRequest(input_url));
diff --git a/net/disk_cache/sparse_control.cc b/net/disk_cache/sparse_control.cc
index 06912de..9f0f537 100644
--- a/net/disk_cache/sparse_control.cc
+++ b/net/disk_cache/sparse_control.cc
@@ -4,6 +4,7 @@
#include "net/disk_cache/sparse_control.h"
+#include "base/format_macros.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/string_util.h"
@@ -40,8 +41,8 @@ const int kBlockSize = 1024;
// number of the particular child.
std::string GenerateChildName(const std::string& base_name, int64 signature,
int64 child_id) {
- return StringPrintf("Range_%s:%llx:%llx", base_name.c_str(), signature,
- child_id);
+ return StringPrintf("Range_%s:%" PRIx64 ":%" PRIx64, base_name.c_str(),
+ signature, child_id);
}
// This class deletes the children of a sparse entry.
diff --git a/net/ftp/ftp_directory_listing_buffer_unittest.cc b/net/ftp/ftp_directory_listing_buffer_unittest.cc
index 9cf557f..97a915e 100644
--- a/net/ftp/ftp_directory_listing_buffer_unittest.cc
+++ b/net/ftp/ftp_directory_listing_buffer_unittest.cc
@@ -5,6 +5,7 @@
#include "net/ftp/ftp_directory_listing_buffer.h"
#include "base/file_util.h"
+#include "base/format_macros.h"
#include "base/path_service.h"
#include "base/string_tokenizer.h"
#include "base/string_util.h"
@@ -36,7 +37,7 @@ TEST(FtpDirectoryListingBufferTest, Parse) {
test_dir = test_dir.AppendASCII("ftp");
for (size_t i = 0; i < arraysize(test_files); i++) {
- SCOPED_TRACE(StringPrintf("Test[%d]: %s", i, test_files[i]));
+ SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, test_files[i]));
net::FtpDirectoryListingBuffer buffer;
diff --git a/net/ftp/ftp_directory_listing_parsers_unittest.cc b/net/ftp/ftp_directory_listing_parsers_unittest.cc
index 8c970914..19c6feb 100644
--- a/net/ftp/ftp_directory_listing_parsers_unittest.cc
+++ b/net/ftp/ftp_directory_listing_parsers_unittest.cc
@@ -4,6 +4,7 @@
#include "net/ftp/ftp_directory_listing_parsers.h"
+#include "base/format_macros.h"
#include "base/string_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -69,7 +70,7 @@ TEST_F(FtpDirectoryListingParsersTest, Ls) {
now_exploded.year, 10, 12, 13, 37 },
};
for (size_t i = 0; i < arraysize(good_cases); i++) {
- SCOPED_TRACE(StringPrintf("Test[%d]: %s", i, good_cases[i].input));
+ SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input));
net::FtpLsDirectoryListingParser parser;
RunSingleLineTestCase(&parser, good_cases[i]);
@@ -128,7 +129,7 @@ TEST_F(FtpDirectoryListingParsersTest, Windows) {
1979, 1, 6, 2, 42 },
};
for (size_t i = 0; i < arraysize(good_cases); i++) {
- SCOPED_TRACE(StringPrintf("Test[%d]: %s", i, good_cases[i].input));
+ SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input));
net::FtpWindowsDirectoryListingParser parser;
RunSingleLineTestCase(&parser, good_cases[i]);
@@ -180,7 +181,7 @@ TEST_F(FtpDirectoryListingParsersTest, Vms) {
2005, 3, 12, 8, 44 },
};
for (size_t i = 0; i < arraysize(good_cases); i++) {
- SCOPED_TRACE(StringPrintf("Test[%d]: %s", i, good_cases[i].input));
+ SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input));
net::FtpVmsDirectoryListingParser parser;
ASSERT_TRUE(
@@ -234,7 +235,7 @@ TEST_F(FtpDirectoryListingParsersTest, Vms) {
"Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RRWWEEDD,RE,RE)",
};
for (size_t i = 0; i < arraysize(bad_cases); i++) {
- SCOPED_TRACE(StringPrintf("Test[%d]: %s", i, bad_cases[i]));
+ SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, bad_cases[i]));
std::vector<std::string> lines;
SplitString(bad_cases[i], '|', &lines);
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index 1fae4ad..7f4c614 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -12,6 +12,7 @@
#include <unistd.h>
#endif
+#include "base/format_macros.h"
#include "base/message_loop.h"
#include "base/pickle.h"
#include "base/ref_counted.h"
@@ -210,8 +211,10 @@ std::string HttpCache::GenerateCacheKey(const HttpRequestInfo* request) {
if (mode_ == NORMAL) {
// No valid URL can begin with numerals, so we should not have to worry
// about collisions with normal URLs.
- if (request->upload_data && request->upload_data->identifier())
- url.insert(0, StringPrintf("%lld/", request->upload_data->identifier()));
+ if (request->upload_data && request->upload_data->identifier()) {
+ url.insert(0, StringPrintf("%" PRId64 "/",
+ request->upload_data->identifier()));
+ }
return url;
}
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index e317990..bdf3e3d 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -4,6 +4,7 @@
#include "net/http/http_network_transaction.h"
+#include "base/format_macros.h"
#include "base/scoped_ptr.h"
#include "base/compiler_specific.h"
#include "base/field_trial.h"
@@ -69,7 +70,7 @@ void BuildRequestHeaders(const HttpRequestInfo* request_info,
// Add a content length header?
if (upload_data_stream) {
- StringAppendF(request_headers, "Content-Length: %llu\r\n",
+ StringAppendF(request_headers, "Content-Length: %" PRIu64 "\r\n",
upload_data_stream->size());
} else if (request_info->method == "POST" || request_info->method == "PUT" ||
request_info->method == "HEAD") {
diff --git a/net/http/partial_data.cc b/net/http/partial_data.cc
index 162948c..f253dc1 100644
--- a/net/http/partial_data.cc
+++ b/net/http/partial_data.cc
@@ -4,6 +4,7 @@
#include "net/http/partial_data.h"
+#include "base/format_macros.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "net/base/net_errors.h"
@@ -237,10 +238,12 @@ void PartialData::FixResponseHeaders(HttpResponseHeaders* headers) {
DCHECK(byte_range_.HasFirstBytePosition());
DCHECK(byte_range_.HasLastBytePosition());
- headers->AddHeader(StringPrintf("%s: bytes %lld-%lld/%lld", kRangeHeader,
- byte_range_.first_byte_position(),
- byte_range_.last_byte_position(),
- resource_size_));
+ headers->AddHeader(
+ StringPrintf("%s: bytes %" PRId64 "-%" PRId64 "/%" PRId64,
+ kRangeHeader,
+ byte_range_.first_byte_position(),
+ byte_range_.last_byte_position(),
+ resource_size_));
range_len = byte_range_.last_byte_position() -
byte_range_.first_byte_position() + 1;
} else {
@@ -250,12 +253,13 @@ void PartialData::FixResponseHeaders(HttpResponseHeaders* headers) {
range_len = resource_size_;
}
- headers->AddHeader(StringPrintf("%s: %lld", kLengthHeader, range_len));
+ headers->AddHeader(StringPrintf("%s: %" PRId64, kLengthHeader, range_len));
}
void PartialData::FixContentLength(HttpResponseHeaders* headers) {
headers->RemoveHeader(kLengthHeader);
- headers->AddHeader(StringPrintf("%s: %lld", kLengthHeader, resource_size_));
+ headers->AddHeader(StringPrintf("%s: %" PRId64, kLengthHeader,
+ resource_size_));
}
int PartialData::CacheRead(disk_cache::Entry* entry, IOBuffer* data,
diff --git a/net/proxy/proxy_config_service_linux_unittest.cc b/net/proxy/proxy_config_service_linux_unittest.cc
index 26149e5..2ffe081 100644
--- a/net/proxy/proxy_config_service_linux_unittest.cc
+++ b/net/proxy/proxy_config_service_linux_unittest.cc
@@ -2,14 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "net/proxy/proxy_config_service_linux.h"
+
#include <map>
#include <string>
#include <vector>
-#include "net/proxy/proxy_config_service_linux.h"
-
#include "base/file_path.h"
#include "base/file_util.h"
+#include "base/format_macros.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "base/task.h"
@@ -17,7 +18,6 @@
#include "base/waitable_event.h"
#include "net/proxy/proxy_config.h"
#include "net/proxy/proxy_config_service_common_unittest.h"
-
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -585,7 +585,8 @@ TEST_F(ProxyConfigServiceLinuxTest, BasicGConfTest) {
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
- SCOPED_TRACE(StringPrintf("Test[%d] %s", i, tests[i].description.c_str()));
+ SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i,
+ tests[i].description.c_str()));
MockEnvironmentVariableGetter* env_getter =
new MockEnvironmentVariableGetter;
MockGConfSettingGetter* gconf_getter = new MockGConfSettingGetter;
@@ -864,7 +865,8 @@ TEST_F(ProxyConfigServiceLinuxTest, BasicEnvTest) {
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
- SCOPED_TRACE(StringPrintf("Test[%d] %s", i, tests[i].description.c_str()));
+ SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i,
+ tests[i].description.c_str()));
MockEnvironmentVariableGetter* env_getter =
new MockEnvironmentVariableGetter;
MockGConfSettingGetter* gconf_getter = new MockGConfSettingGetter;
@@ -1185,7 +1187,8 @@ TEST_F(ProxyConfigServiceLinuxTest, KDEConfigParser) {
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
- SCOPED_TRACE(StringPrintf("Test[%d] %s", i, tests[i].description.c_str()));
+ SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i,
+ tests[i].description.c_str()));
MockEnvironmentVariableGetter* env_getter =
new MockEnvironmentVariableGetter;
// Force the KDE getter to be used and tell it where the test is.
diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc
index b7c7d00..6dbee99 100644
--- a/net/proxy/proxy_service_unittest.cc
+++ b/net/proxy/proxy_service_unittest.cc
@@ -2,8 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "net/proxy/proxy_service.h"
+
#include <vector>
+#include "base/format_macros.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "googleurl/src/gurl.h"
@@ -15,7 +18,6 @@
#include "net/proxy/proxy_config_service.h"
#include "net/proxy/proxy_resolver.h"
#include "net/proxy/proxy_script_fetcher.h"
-#include "net/proxy/proxy_service.h"
#include "testing/gtest/include/gtest/gtest.h"
// TODO(eroman): Write a test which exercises
@@ -1474,7 +1476,7 @@ TEST(ProxyServiceTest, IsLocalName) {
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
- SCOPED_TRACE(StringPrintf("Test[%d]: %s", i, tests[i].url));
+ SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, tests[i].url));
bool is_local = ProxyService::IsLocalName(GURL(tests[i].url));
EXPECT_EQ(tests[i].expected_is_local, is_local);
}
diff --git a/net/url_request/request_tracker_unittest.cc b/net/url_request/request_tracker_unittest.cc
index 452d35b..760d5be 100644
--- a/net/url_request/request_tracker_unittest.cc
+++ b/net/url_request/request_tracker_unittest.cc
@@ -5,6 +5,7 @@
#include "net/url_request/request_tracker.h"
#include "base/compiler_specific.h"
+#include "base/format_macros.h"
#include "base/string_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -91,7 +92,7 @@ TEST(RequestTrackerTest, GraveyardBounded) {
for (size_t i = 0;
i < RequestTracker<TestRequest>::kMaxGraveyardSize * 2;
++i) {
- TestRequest req(GURL(StringPrintf("http://req%d", i).c_str()));
+ TestRequest req(GURL(StringPrintf("http://req%" PRIuS, i).c_str()));
tracker.Add(&req);
tracker.Remove(&req);
}
@@ -105,7 +106,7 @@ TEST(RequestTrackerTest, GraveyardBounded) {
for (size_t i = 0; i < RequestTracker<TestRequest>::kMaxGraveyardSize; ++i) {
size_t req_number = i + RequestTracker<TestRequest>::kMaxGraveyardSize;
- GURL url(StringPrintf("http://req%d", req_number).c_str());
+ GURL url(StringPrintf("http://req%" PRIuS, req_number).c_str());
EXPECT_EQ(url, recent_reqs[i].original_url);
}
}
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index 0877768..16af0d0 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -17,6 +17,7 @@
#include <string>
#include "base/file_util.h"
+#include "base/format_macros.h"
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/process_util.h"
@@ -704,9 +705,9 @@ TEST_F(URLRequestTest, FileTestFullSpecifiedRange) {
{
TestURLRequest r(temp_url, &d);
- r.SetExtraRequestHeaders(StringPrintf("Range: bytes=%d-%d\n",
- first_byte_position,
- last_byte_position));
+ r.SetExtraRequestHeaders(
+ StringPrintf("Range: bytes=%" PRIuS "-%" PRIuS "\n",
+ first_byte_position, last_byte_position));
r.Start();
EXPECT_TRUE(r.is_pending());
@@ -745,7 +746,7 @@ TEST_F(URLRequestTest, FileTestHalfSpecifiedRange) {
{
TestURLRequest r(temp_url, &d);
- r.SetExtraRequestHeaders(StringPrintf("Range: bytes=%d-\n",
+ r.SetExtraRequestHeaders(StringPrintf("Range: bytes=%" PRIuS "-\n",
first_byte_position));
r.Start();
EXPECT_TRUE(r.is_pending());
diff --git a/net/url_request/url_request_view_net_internals_job.cc b/net/url_request/url_request_view_net_internals_job.cc
index b98e9ef..e9682dd 100644
--- a/net/url_request/url_request_view_net_internals_job.cc
+++ b/net/url_request/url_request_view_net_internals_job.cc
@@ -12,6 +12,7 @@
#include <sstream>
+#include "base/format_macros.h"
#include "base/stl_util-inl.h"
#include "base/string_util.h"
#include "net/base/escape.h"
@@ -216,9 +217,9 @@ class HostResolverCacheSubSection : public SubSection {
return;
}
- out->append(StringPrintf("<ul><li>Size: %u</li>"
- "<li>Capacity: %u</li>"
- "<li>Time to live (ms): %u</li></ul>",
+ out->append(StringPrintf("<ul><li>Size: %" PRIuS "</li>"
+ "<li>Capacity: %" PRIuS "</li>"
+ "<li>Time to live (ms): %" PRIuS "</li></ul>",
host_cache->size(),
host_cache->max_entries(),
host_cache->cache_duration_ms()));