diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-20 06:53:28 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-20 06:53:28 +0000 |
commit | 34b2b007db875a6acb853c5cd2a247fbb32c0f88 (patch) | |
tree | 6dc39bc9f10d6e8eedcdf14821ba9e96b5ccab51 /chrome/browser | |
parent | 24b857793e27aded8d804a112a5fe6c77e28b081 (diff) | |
download | chromium_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 'chrome/browser')
-rw-r--r-- | chrome/browser/bug_report_util.cc | 2 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_service.cc | 10 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context_unittest.cc | 8 | ||||
-rw-r--r-- | chrome/browser/net/dns_host_info.cc | 5 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/protocol_parser.cc | 7 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_database_unittest.cc | 13 |
6 files changed, 23 insertions, 22 deletions
diff --git a/chrome/browser/bug_report_util.cc b/chrome/browser/bug_report_util.cc index 88907b8..fb40773 100644 --- a/chrome/browser/bug_report_util.cc +++ b/chrome/browser/bug_report_util.cc @@ -193,7 +193,7 @@ void BugReportUtil::SendReport(Profile* profile, post_body.append("Content-Disposition: form-data; name=\"screenshot\"; " "filename=\"screenshot.png\"\r\n"); post_body.append("Content-Type: application/octet-stream\r\n"); - post_body.append(StringPrintf("Content-Length: %lu\r\n\r\n", + post_body.append(StringPrintf("Content-Length: %d\r\n\r\n", png_data_length)); post_body.append(png_data, png_data_length); post_body.append("\r\n"); diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index 79f1a8e..9eaa09d 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -777,11 +777,11 @@ std::string MetricsService::GenerateClientID() { // TODO(cmasone): Once we're comfortable this works, migrate Windows code to // use this as well. std::string MetricsService::RandomBytesToGUIDString(const uint64 bytes[2]) { - return StringPrintf("%08llX-%04llX-%04llX-%04llX-%012llX", - bytes[0] >> 32, - (bytes[0] >> 16) & 0x0000ffff, - bytes[0] & 0x0000ffff, - bytes[1] >> 48, + return StringPrintf("%08X-%04X-%04X-%04X-%012llX", + static_cast<unsigned int>(bytes[0] >> 32), + static_cast<unsigned int>((bytes[0] >> 16) & 0x0000ffff), + static_cast<unsigned int>(bytes[0] & 0x0000ffff), + static_cast<unsigned int>(bytes[1] >> 48), bytes[1] & 0x0000ffffffffffffULL); } #endif diff --git a/chrome/browser/net/chrome_url_request_context_unittest.cc b/chrome/browser/net/chrome_url_request_context_unittest.cc index 4b70ca9..e1ac43e 100644 --- a/chrome/browser/net/chrome_url_request_context_unittest.cc +++ b/chrome/browser/net/chrome_url_request_context_unittest.cc @@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/command_line.h" #include "chrome/browser/net/chrome_url_request_context.h" + +#include "base/command_line.h" +#include "base/format_macros.h" #include "chrome/common/chrome_switches.h" #include "net/proxy/proxy_config.h" #include "net/proxy/proxy_config_service_common_unittest.h" - #include "testing/gtest/include/gtest/gtest.h" // Builds an identifier for each test in an array. @@ -163,7 +164,8 @@ TEST(ChromeUrlRequestContextTest, CreateProxyConfigTest) { }; 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())); scoped_ptr<net::ProxyConfig> config(CreateProxyConfig( CommandLine(tests[i].command_line))); diff --git a/chrome/browser/net/dns_host_info.cc b/chrome/browser/net/dns_host_info.cc index dbfde3b..63eae34 100644 --- a/chrome/browser/net/dns_host_info.cc +++ b/chrome/browser/net/dns_host_info.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// See header file for description of class - #include "chrome/browser/net/dns_host_info.h" #include <math.h> @@ -11,6 +9,7 @@ #include <algorithm> #include <string> +#include "base/format_macros.h" #include "base/histogram.h" #include "base/logging.h" #include "base/string_util.h" @@ -326,7 +325,7 @@ void DnsHostInfo::GetHtmlTable(const DnsInfoTable host_infos, if (0 == host_infos.size()) return; output->append(description); - StringAppendF(output, "%d %s", host_infos.size(), + StringAppendF(output, "%" PRIuS " %s", host_infos.size(), (1 == host_infos.size()) ? "hostname" : "hostnames"); if (brief) { diff --git a/chrome/browser/safe_browsing/protocol_parser.cc b/chrome/browser/safe_browsing/protocol_parser.cc index ce8474c..c2aa793 100644 --- a/chrome/browser/safe_browsing/protocol_parser.cc +++ b/chrome/browser/safe_browsing/protocol_parser.cc @@ -4,6 +4,8 @@ // // Parse the data returned from the SafeBrowsing v2.1 protocol response. +#include "chrome/browser/safe_browsing/protocol_parser.h" + #include "build/build_config.h" #if defined(OS_WIN) @@ -12,8 +14,7 @@ #include <arpa/inet.h> #endif -#include "chrome/browser/safe_browsing/protocol_parser.h" - +#include "base/format_macros.h" #include "base/logging.h" #include "base/string_util.h" @@ -115,7 +116,7 @@ void SafeBrowsingProtocolParser::FormatGetHash( DCHECK(request); // Format the request for GetHash. - request->append(StringPrintf("%d:%d\n", + request->append(StringPrintf("%" PRIuS ":%" PRIuS "\n", sizeof(SBPrefix), sizeof(SBPrefix) * prefixes.size())); for (size_t i = 0; i < prefixes.size(); ++i) { diff --git a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc index 0e41133..c8efc3d 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc @@ -5,6 +5,7 @@ // Unit tests for the SafeBrowsing storage system. #include "base/file_util.h" +#include "base/format_macros.h" #include "base/logging.h" #include "base/path_service.h" #include "base/process_util.h" @@ -1058,8 +1059,6 @@ struct ChunksInfo { void PeformUpdate(const std::wstring& initial_db, const std::vector<ChunksInfo>& chunks, std::vector<SBChunkDelete>* deletes) { -// TODO(pinkerton): I don't think posix has any concept of IO counters, but -// we can uncomment this when we implement ProcessMetrics::GetIOCounters IoCounters before, after; FilePath path; @@ -1096,15 +1095,15 @@ void PeformUpdate(const std::wstring& initial_db, CHECK(metric->GetIOCounters(&after)); - LOG(INFO) << StringPrintf("I/O Read Bytes: %d", + LOG(INFO) << StringPrintf("I/O Read Bytes: %" PRIu64, after.ReadTransferCount - before.ReadTransferCount); - LOG(INFO) << StringPrintf("I/O Write Bytes: %d", + LOG(INFO) << StringPrintf("I/O Write Bytes: %" PRIu64, after.WriteTransferCount - before.WriteTransferCount); - LOG(INFO) << StringPrintf("I/O Reads: %d", + LOG(INFO) << StringPrintf("I/O Reads: %" PRIu64, after.ReadOperationCount - before.ReadOperationCount); - LOG(INFO) << StringPrintf("I/O Writes: %d", + LOG(INFO) << StringPrintf("I/O Writes: %" PRIu64, after.WriteOperationCount - before.WriteOperationCount); - LOG(INFO) << StringPrintf("Finished in %d ms", + LOG(INFO) << StringPrintf("Finished in %" PRId64 " ms", (Time::Now() - before_time).InMilliseconds()); PrintStat("c:SB.HostSelect"); |