summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/compiler_specific.h21
-rw-r--r--base/format_macros.h15
-rw-r--r--base/histogram.cc7
-rw-r--r--base/i18n/number_formatting.cc3
-rw-r--r--base/process_util.h12
-rw-r--r--base/string_util.h36
-rw-r--r--base/string_util_unittest.cc33
-rw-r--r--base/trace_event.cc6
-rw-r--r--base/tracked_objects.cc10
-rw-r--r--base/worker_pool_linux.cc3
-rw-r--r--chrome/app/chrome_dll_main.cc5
-rw-r--r--chrome/browser/bug_report_util.cc2
-rw-r--r--chrome/browser/metrics/metrics_service.cc10
-rw-r--r--chrome/browser/net/chrome_url_request_context_unittest.cc8
-rw-r--r--chrome/browser/net/dns_host_info.cc5
-rw-r--r--chrome/browser/safe_browsing/protocol_parser.cc7
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_database_unittest.cc13
-rw-r--r--chrome/common/child_process_info.cc2
-rw-r--r--chrome/common/extensions/extension_unittest.cc16
-rw-r--r--courgette/adjustment_method_2.cc13
-rw-r--r--media/base/video_frame_impl_unittest.cc6
-rw-r--r--media/filters/ffmpeg_glue.cc2
-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
-rw-r--r--webkit/glue/dom_serializer.cc6
-rw-r--r--webkit/glue/media/buffered_data_source_unittest.cc7
-rw-r--r--webkit/glue/media/media_resource_loader_bridge_factory.cc8
40 files changed, 236 insertions, 135 deletions
diff --git a/base/compiler_specific.h b/base/compiler_specific.h
index 50dc6f3..23b9f124 100644
--- a/base/compiler_specific.h
+++ b/base/compiler_specific.h
@@ -67,11 +67,32 @@
#if defined(COMPILER_GCC)
+
#define ALLOW_UNUSED __attribute__((unused))
#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+
+// Tell the compiler a function is using a printf-style format string.
+// |format_param| is the one-based index of the format string parameter;
+// |dots_param| is the one-based index of the "..." parameter.
+// For v*printf functions (which take a va_list), pass 0 for dots_param.
+// (This is undocumented but matches what the system C headers do.)
+#define PRINTF_FORMAT(format_param, dots_param) \
+ __attribute__((format(printf, format_param, dots_param)))
+
+// WPRINTF_FORMAT is the same, but for wide format strings.
+// This doesn't appear to yet be implemented.
+// See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 .
+#define WPRINTF_FORMAT(format_param, dots_param)
+// If available, it would look like:
+// __attribute__((format(wprintf, format_param, dots_param)))
+
#else // Not GCC
+
#define ALLOW_UNUSED
#define WARN_UNUSED_RESULT
+#define PRINTF_FORMAT(x, y)
+#define WPRINTF_FORMAT(x, y)
+
#endif
#endif // BASE_COMPILER_SPECIFIC_H_
diff --git a/base/format_macros.h b/base/format_macros.h
index 383579f..d218f48 100644
--- a/base/format_macros.h
+++ b/base/format_macros.h
@@ -5,14 +5,21 @@
#ifndef BASE_FORMAT_MACROS_H_
#define BASE_FORMAT_MACROS_H_
-// This file defines the C99 format macros for 64-bit values. If you wish to
-// print a 64-bit value in a portable way do:
+// This file defines the format macros for some integer types.
+
+// To print a 64-bit value in a portable way:
// int64_t value;
// printf("xyz:%" PRId64, value);
+// The "d" in the macro corresponds to %d; you can also use PRIu64 etc.
//
// For wide strings, prepend "Wide" to the macro:
// int64_t value;
// StringPrintf(L"xyz: %" WidePRId64, value);
+//
+// To print a size_t value in a portable way:
+// size_t size;
+// printf("xyz: %" PRIuS, size);
+// The "u" in the macro corresponds to %u, and S is for "size".
#include "build/build_config.h"
@@ -35,6 +42,8 @@
#define WidePRIu64 PRIu64
#define WidePRIx64 PRIx64
+#define PRIuS "zu"
+
#else // OS_WIN
#if !defined(PRId64)
@@ -53,6 +62,8 @@
#define WidePRIu64 L"I64u"
#define WidePRIx64 L"I64x"
+#define PRIuS "Iu"
+
#endif
#endif // !BASE_FORMAT_MACROS_H_
diff --git a/base/histogram.cc b/base/histogram.cc
index 3d2cd9e..55af96d 100644
--- a/base/histogram.cc
+++ b/base/histogram.cc
@@ -124,7 +124,10 @@ void Histogram::WriteAscii(bool graph_it, const std::string& newline,
if (!current && !PrintEmptyBucket(i))
continue;
remaining -= current;
- StringAppendF(output, "%#*s ", print_width, GetAsciiBucketRange(i).c_str());
+ std::string range = GetAsciiBucketRange(i);
+ output->append(range);
+ for (size_t j = 0; range.size() + j < print_width + 1; ++j)
+ output->push_back(' ');
if (0 == current && i < bucket_count() - 1 && 0 == snapshot.counts(i + 1)) {
while (i < bucket_count() - 1 && 0 == snapshot.counts(i + 1))
++i;
@@ -287,7 +290,7 @@ void Histogram::WriteAsciiHeader(const SampleSet& snapshot,
Count sample_count,
std::string* output) const {
StringAppendF(output,
- "Histogram: %s recorded %ld samples",
+ "Histogram: %s recorded %d samples",
histogram_name().c_str(),
sample_count);
if (0 == sample_count) {
diff --git a/base/i18n/number_formatting.cc b/base/i18n/number_formatting.cc
index fef1b7d..7a69294 100644
--- a/base/i18n/number_formatting.cc
+++ b/base/i18n/number_formatting.cc
@@ -4,6 +4,7 @@
#include "base/i18n/number_formatting.h"
+#include "base/format_macros.h"
#include "base/logging.h"
#include "base/singleton.h"
#include "base/string_util.h"
@@ -37,7 +38,7 @@ string16 FormatNumber(int64 number) {
if (!number_format) {
// As a fallback, just return the raw number in a string.
- return UTF8ToUTF16(StringPrintf("%lld", number));
+ return UTF8ToUTF16(StringPrintf("%" PRId64, number));
}
icu::UnicodeString ustr;
number_format->format(number, ustr);
diff --git a/base/process_util.h b/base/process_util.h
index a6f63ac..cd26c2a 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -43,12 +43,12 @@ struct ProcessEntry {
};
struct IoCounters {
- unsigned long long ReadOperationCount;
- unsigned long long WriteOperationCount;
- unsigned long long OtherOperationCount;
- unsigned long long ReadTransferCount;
- unsigned long long WriteTransferCount;
- unsigned long long OtherTransferCount;
+ uint64_t ReadOperationCount;
+ uint64_t WriteOperationCount;
+ uint64_t OtherOperationCount;
+ uint64_t ReadTransferCount;
+ uint64_t WriteTransferCount;
+ uint64_t OtherTransferCount;
};
#include "base/file_descriptor_shuffle.h"
diff --git a/base/string_util.h b/base/string_util.h
index 89caf4f..6d4a4d9 100644
--- a/base/string_util.h
+++ b/base/string_util.h
@@ -13,6 +13,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/compiler_specific.h"
#include "base/string16.h"
#include "base/string_piece.h" // For implicit conversions.
@@ -42,17 +43,22 @@ int strncasecmp(const char* s1, const char* s2, size_t count);
// Wrapper for vsnprintf that always null-terminates and always returns the
// number of characters that would be in an untruncated formatted
// string, even when truncation occurs.
-int vsnprintf(char* buffer, size_t size, const char* format, va_list arguments);
+int vsnprintf(char* buffer, size_t size, const char* format, va_list arguments)
+ PRINTF_FORMAT(3, 0);
// vswprintf always null-terminates, but when truncation occurs, it will either
// return -1 or the number of characters that would be in an untruncated
// formatted string. The actual return value depends on the underlying
// C library's vswprintf implementation.
int vswprintf(wchar_t* buffer, size_t size,
- const wchar_t* format, va_list arguments);
+ const wchar_t* format, va_list arguments) WPRINTF_FORMAT(3, 0);
// Some of these implementations need to be inlined.
+// We separate the declaration from the implementation of this inline
+// function just so the PRINTF_FORMAT works.
+inline int snprintf(char* buffer, size_t size, const char* format, ...)
+ PRINTF_FORMAT(3, 4);
inline int snprintf(char* buffer, size_t size, const char* format, ...) {
va_list arguments;
va_start(arguments, format);
@@ -61,6 +67,10 @@ inline int snprintf(char* buffer, size_t size, const char* format, ...) {
return result;
}
+// We separate the declaration from the implementation of this inline
+// function just so the WPRINTF_FORMAT works.
+inline int swprintf(wchar_t* buffer, size_t size, const wchar_t* format, ...)
+ WPRINTF_FORMAT(3, 4);
inline int swprintf(wchar_t* buffer, size_t size, const wchar_t* format, ...) {
va_list arguments;
va_start(arguments, format);
@@ -438,22 +448,28 @@ double StringToDouble(const std::string& value);
double StringToDouble(const string16& value);
// Return a C++ string given printf-like input.
-std::string StringPrintf(const char* format, ...);
-std::wstring StringPrintf(const wchar_t* format, ...);
+std::string StringPrintf(const char* format, ...) PRINTF_FORMAT(1, 2);
+std::wstring StringPrintf(const wchar_t* format, ...) WPRINTF_FORMAT(1, 2);
// Store result into a supplied string and return it
-const std::string& SStringPrintf(std::string* dst, const char* format, ...);
+const std::string& SStringPrintf(std::string* dst, const char* format, ...)
+ PRINTF_FORMAT(2, 3);
const std::wstring& SStringPrintf(std::wstring* dst,
- const wchar_t* format, ...);
+ const wchar_t* format, ...)
+ WPRINTF_FORMAT(2, 3);
// Append result to a supplied string
-void StringAppendF(std::string* dst, const char* format, ...);
-void StringAppendF(std::wstring* dst, const wchar_t* format, ...);
+void StringAppendF(std::string* dst, const char* format, ...)
+ PRINTF_FORMAT(2, 3);
+void StringAppendF(std::wstring* dst, const wchar_t* format, ...)
+ WPRINTF_FORMAT(2, 3);
// Lower-level routine that takes a va_list and appends to a specified
// string. All other routines are just convenience wrappers around it.
-void StringAppendV(std::string* dst, const char* format, va_list ap);
-void StringAppendV(std::wstring* dst, const wchar_t* format, va_list ap);
+void StringAppendV(std::string* dst, const char* format, va_list ap)
+ PRINTF_FORMAT(2, 0);
+void StringAppendV(std::wstring* dst, const wchar_t* format, va_list ap)
+ WPRINTF_FORMAT(2, 0);
// This is mpcomplete's pattern for saving a string copy when dealing with
// a function that writes results into a wchar_t[] and wanting the result to
diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc
index d691003..c586ff4 100644
--- a/base/string_util_unittest.cc
+++ b/base/string_util_unittest.cc
@@ -827,9 +827,7 @@ TEST(StringUtilTest, VAList) {
VariableArgsFunc("%d %d %s %lf", 45, 92, "This is interesting", 9.21);
}
-TEST(StringUtilTest, StringPrintfEmptyFormat) {
- const char* empty = "";
- EXPECT_EQ("", StringPrintf(empty));
+TEST(StringUtilTest, StringPrintfEmpty) {
EXPECT_EQ("", StringPrintf("%s", ""));
}
@@ -838,16 +836,6 @@ TEST(StringUtilTest, StringPrintfMisc) {
EXPECT_EQ(L"123hello w", StringPrintf(L"%3d%2ls %1lc", 123, L"hello", 'w'));
}
-TEST(StringUtilTest, StringAppendfStringEmptyParam) {
- std::string value("Hello");
- StringAppendF(&value, "");
- EXPECT_EQ("Hello", value);
-
- std::wstring valuew(L"Hello");
- StringAppendF(&valuew, L"");
- EXPECT_EQ(L"Hello", valuew);
-}
-
TEST(StringUtilTest, StringAppendfEmptyString) {
std::string value("Hello");
StringAppendF(&value, "%s", "");
@@ -926,6 +914,25 @@ TEST(StringUtilTest, Grow) {
delete[] ref;
}
+// A helper for the StringAppendV test that follows.
+// Just forwards its args to StringAppendV.
+static void StringAppendVTestHelper(std::string* out,
+ const char* format,
+ ...) PRINTF_FORMAT(2, 3);
+
+static void StringAppendVTestHelper(std::string* out, const char* format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ StringAppendV(out, format, ap);
+ va_end(ap);
+}
+
+TEST(StringUtilTest, StringAppendV) {
+ std::string out;
+ StringAppendVTestHelper(&out, "%d foo %s", 1, "bar");
+ EXPECT_EQ("1 foo bar", out);
+}
+
// Test the boundary condition for the size of the string_util's
// internal buffer.
TEST(StringUtilTest, GrowBoundary) {
diff --git a/base/trace_event.cc b/base/trace_event.cc
index be2fbaa..13c0c2c 100644
--- a/base/trace_event.cc
+++ b/base/trace_event.cc
@@ -133,10 +133,10 @@ void TraceLog::Trace(const std::string& name,
int64 usec = delta.InMicroseconds();
std::string msg =
StringPrintf("{'pid':'0x%lx', 'tid':'0x%lx', 'type':'%s', "
- "'name':'%s', 'id':'0x%lx', 'extra':'%s', 'file':'%s', "
+ "'name':'%s', 'id':'%p', 'extra':'%s', 'file':'%s', "
"'line_number':'%d', 'usec_begin': %" PRId64 "},\n",
- base::GetCurrentProcId(),
- PlatformThread::CurrentId(),
+ static_cast<unsigned long>(base::GetCurrentProcId()),
+ static_cast<unsigned long>(PlatformThread::CurrentId()),
kEventTypeNames[type],
name.c_str(),
id,
diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc
index 1e7d293..0d68703 100644
--- a/base/tracked_objects.cc
+++ b/base/tracked_objects.cc
@@ -6,6 +6,7 @@
#include <math.h>
+#include "base/format_macros.h"
#include "base/message_loop.h"
#include "base/string_util.h"
@@ -551,22 +552,23 @@ void Aggregation::Write(std::string* output) const {
if (locations_.size() == 1) {
locations_.begin()->first.Write(true, true, output);
} else {
- StringAppendF(output, "%d Locations. ", locations_.size());
+ StringAppendF(output, "%" PRIuS " Locations. ", locations_.size());
if (birth_files_.size() > 1)
- StringAppendF(output, "%d Files. ", birth_files_.size());
+ StringAppendF(output, "%" PRIuS " Files. ", birth_files_.size());
else
StringAppendF(output, "All born in %s. ",
birth_files_.begin()->first.c_str());
}
if (birth_threads_.size() > 1)
- StringAppendF(output, "%d BirthingThreads. ", birth_threads_.size());
+ StringAppendF(output, "%" PRIuS " BirthingThreads. ",
+ birth_threads_.size());
else
StringAppendF(output, "All born on %s. ",
birth_threads_.begin()->first->ThreadName().c_str());
if (death_threads_.size() > 1) {
- StringAppendF(output, "%d DeathThreads. ", death_threads_.size());
+ StringAppendF(output, "%" PRIuS " DeathThreads. ", death_threads_.size());
} else {
if (death_threads_.begin()->first)
StringAppendF(output, "All deleted on %s. ",
diff --git a/base/worker_pool_linux.cc b/base/worker_pool_linux.cc
index 31fcef1..b9c85b3 100644
--- a/base/worker_pool_linux.cc
+++ b/base/worker_pool_linux.cc
@@ -67,8 +67,7 @@ class WorkerThread : public PlatformThread::Delegate {
void WorkerThread::ThreadMain() {
const std::string name =
- StringPrintf("%s/%d", name_prefix_.c_str(),
- IntToString(PlatformThread::CurrentId()).c_str());
+ StringPrintf("%s/%d", name_prefix_.c_str(), PlatformThread::CurrentId());
PlatformThread::SetName(name.c_str());
for (;;) {
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc
index c075d88..6475ced 100644
--- a/chrome/app/chrome_dll_main.cc
+++ b/chrome/app/chrome_dll_main.cc
@@ -460,8 +460,9 @@ int ChromeMain(int argc, char** argv) {
// leaking shared memory regions on posix platforms.
if (parsed_command_line.HasSwitch(switches::kEnableStatsTable) ||
parsed_command_line.HasSwitch(switches::kEnableBenchmarking)) {
- std::string statsfile = StringPrintf("%s-%lld", chrome::kStatsFilename,
- static_cast<int64>(browser_pid));
+ std::string statsfile =
+ StringPrintf("%s-%u", chrome::kStatsFilename,
+ static_cast<unsigned int>(browser_pid));
StatsTable *stats_table = new StatsTable(statsfile,
chrome::kStatsMaxThreads, chrome::kStatsMaxCounters);
StatsTable::set_current(stats_table);
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");
diff --git a/chrome/common/child_process_info.cc b/chrome/common/child_process_info.cc
index 4eafde8..c915e80 100644
--- a/chrome/common/child_process_info.cc
+++ b/chrome/common/child_process_info.cc
@@ -106,7 +106,7 @@ std::string ChildProcessInfo::GenerateRandomChannelID(void* instance) {
// parent browser process, an identifier for the child instance, and a random
// component. We use a random component so that a hacked child process can't
// cause denial of service by causing future named pipe creation to fail.
- return StringPrintf("%d.%x.%d",
+ return StringPrintf("%d.%p.%d",
base::GetCurrentProcId(), instance,
base::RandInt(0, std::numeric_limits<int>::max()));
}
diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc
index db54776..330478c 100644
--- a/chrome/common/extensions/extension_unittest.cc
+++ b/chrome/common/extensions/extension_unittest.cc
@@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/common/extensions/extension.h"
+
+#include "base/format_macros.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/string_util.h"
#include "base/path_service.h"
#include "chrome/common/chrome_paths.h"
-#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_error_reporter.h"
#include "chrome/common/json_value_serializer.h"
@@ -472,9 +474,11 @@ TEST(ExtensionTest, UpdateUrls) {
DictionaryValue input_value;
#if defined(OS_WIN)
- FilePath path(StringPrintf(L"c:\\extension%i", i));
+ // (Why %Iu below? This is the single file in the whole code base that
+ // might make use of a WidePRIuS; let's not encourage any more.)
+ FilePath path(StringPrintf(L"c:\\extension%Iu", i));
#else
- FilePath path(StringPrintf("/extension%i", i));
+ FilePath path(StringPrintf("/extension%" PRIuS, i));
#endif
Extension extension(path);
std::string error;
@@ -494,9 +498,11 @@ TEST(ExtensionTest, UpdateUrls) {
for (size_t i = 0; i < invalid.size(); i++) {
DictionaryValue input_value;
#if defined(OS_WIN)
- FilePath path(StringPrintf(L"c:\\extension%i", i));
+ // (Why %Iu below? This is the single file in the whole code base that
+ // might make use of a WidePRIuS; let's not encourage any more.)
+ FilePath path(StringPrintf(L"c:\\extension%Iu", i));
#else
- FilePath path(StringPrintf("/extension%i", i));
+ FilePath path(StringPrintf("/extension%" PRIuS, i));
#endif
Extension extension(path);
std::string error;
diff --git a/courgette/adjustment_method_2.cc b/courgette/adjustment_method_2.cc
index 49fcf49..9cb9dbd 100644
--- a/courgette/adjustment_method_2.cc
+++ b/courgette/adjustment_method_2.cc
@@ -15,6 +15,7 @@
#include <iostream>
#include "base/basictypes.h"
+#include "base/format_macros.h"
#include "base/logging.h"
#include "base/string_util.h"
@@ -461,8 +462,8 @@ std::string ToString(const Shingle* instance) {
s += ToString(instance->at(i));
sep = ", ";
}
- StringAppendF(&s, ">(%u)@{%d}", instance->exemplar_position_,
- static_cast<int>(instance->position_count()));
+ StringAppendF(&s, ">(%" PRIuS ")@{%" PRIuS "}", instance->exemplar_position_,
+ instance->position_count());
return s;
}
@@ -578,7 +579,7 @@ std::string HistogramToString(const ShinglePattern::Histogram& histogram,
s += " ...";
break;
}
- StringAppendF(&s, " %d", p->count());
+ StringAppendF(&s, " %" PRIuS, p->count());
}
return s;
}
@@ -598,7 +599,7 @@ std::string HistogramToStringFull(const ShinglePattern::Histogram& histogram,
s += "...\n";
break;
}
- StringAppendF(&s, "(%d) ", p->count());
+ StringAppendF(&s, "(%" PRIuS ") ", p->count());
s += ToString(&(*p->instance()));
s += "\n";
}
@@ -633,9 +634,9 @@ std::string ShinglePatternToStringFull(const ShinglePattern* pattern,
s += "\n";
size_t model_size = pattern->model_histogram_.size();
size_t program_size = pattern->program_histogram_.size();
- StringAppendF(&s, " model shingles %u\n", model_size);
+ StringAppendF(&s, " model shingles %" PRIuS "\n", model_size);
s += HistogramToStringFull(pattern->model_histogram_, " ", max);
- StringAppendF(&s, " program shingles %u\n", program_size);
+ StringAppendF(&s, " program shingles %" PRIuS "\n", program_size);
s += HistogramToStringFull(pattern->program_histogram_, " ", max);
return s;
}
diff --git a/media/base/video_frame_impl_unittest.cc b/media/base/video_frame_impl_unittest.cc
index 9d9573c..d50db36 100644
--- a/media/base/video_frame_impl_unittest.cc
+++ b/media/base/video_frame_impl_unittest.cc
@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "media/base/video_frame_impl.h"
+
+#include "base/format_macros.h"
#include "base/string_util.h"
#include "media/base/buffers.h"
#include "media/base/mock_filters.h"
-#include "media/base/video_frame_impl.h"
#include "media/base/yuv_convert.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -84,7 +86,7 @@ void ExpectFrameColor(media::VideoFrame* yv12_frame, uint32 expect_rgb_color) {
rgb_surface.data[VideoSurface::kRGBPlane] +
(rgb_surface.strides[VideoSurface::kRGBPlane] * row));
for (size_t col = 0; col < rgb_surface.width; ++col) {
- SCOPED_TRACE(StringPrintf("Checking (%u, %u)", row, col));
+ SCOPED_TRACE(StringPrintf("Checking (%" PRIuS ", %" PRIuS ")", row, col));
EXPECT_EQ(expect_rgb_color, rgb_row_data[col]);
}
}
diff --git a/media/filters/ffmpeg_glue.cc b/media/filters/ffmpeg_glue.cc
index 3c8433c..77b1f33 100644
--- a/media/filters/ffmpeg_glue.cc
+++ b/media/filters/ffmpeg_glue.cc
@@ -151,7 +151,7 @@ std::string FFmpegGlue::GetProtocolKey(FFmpegURLProtocol* protocol) {
// Use the FFmpegURLProtocol's memory address to generate the unique string.
// This also has the nice property that adding the same FFmpegURLProtocol
// reference will not generate duplicate entries.
- return StringPrintf("%s://0x%lx", kProtocol, static_cast<void*>(protocol));
+ return StringPrintf("%s://%p", kProtocol, static_cast<void*>(protocol));
}
} // namespace media
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()));
diff --git a/webkit/glue/dom_serializer.cc b/webkit/glue/dom_serializer.cc
index a7b469b..d8cf3a4 100644
--- a/webkit/glue/dom_serializer.cc
+++ b/webkit/glue/dom_serializer.cc
@@ -49,6 +49,10 @@
// override the incorrect base URL and make sure we alway load correct local
// saved resource files.
+// We must include format_macros up here, before any WebKit headers
+// include inttypes.h.
+#include "base/format_macros.h"
+
#include "config.h"
#include "base/compiler_specific.h"
@@ -87,7 +91,7 @@ namespace {
// Default "mark of the web" declaration
static const char* const kDefaultMarkOfTheWeb =
- "\n<!-- saved from url=(%04d)%s -->\n";
+ "\n<!-- saved from url=(%04" PRIuS ")%s -->\n";
// Default meat content for writing correct charset declaration.
static const wchar_t* const kDefaultMetaContent =
diff --git a/webkit/glue/media/buffered_data_source_unittest.cc b/webkit/glue/media/buffered_data_source_unittest.cc
index f96bac1..9b6151d 100644
--- a/webkit/glue/media/buffered_data_source_unittest.cc
+++ b/webkit/glue/media/buffered_data_source_unittest.cc
@@ -4,6 +4,7 @@
#include <algorithm>
+#include "base/format_macros.h"
#include "base/string_util.h"
#include "media/base/filters.h"
#include "media/base/mock_filter_host.h"
@@ -92,7 +93,8 @@ class BufferedResourceLoaderTest : public testing::Test {
EXPECT_CALL(*this, StartCallback(net::OK));
ResourceLoaderBridge::ResponseInfo info;
std::string header = StringPrintf("HTTP/1.1 200 OK\n"
- "Content-Length: %lld", instance_size);
+ "Content-Length: %" PRId64,
+ instance_size);
replace(header.begin(), header.end(), '\n', '\0');
info.headers = new net::HttpResponseHeaders(header);
info.content_length = instance_size;
@@ -108,7 +110,8 @@ class BufferedResourceLoaderTest : public testing::Test {
int64 content_length = last_position - first_position + 1;
ResourceLoaderBridge::ResponseInfo info;
std::string header = StringPrintf("HTTP/1.1 206 Partial Content\n"
- "Content-Range: bytes %lld-%lld/%lld",
+ "Content-Range: bytes "
+ "%" PRId64 "-%" PRId64 "/%" PRId64,
first_position,
last_position,
instance_size);
diff --git a/webkit/glue/media/media_resource_loader_bridge_factory.cc b/webkit/glue/media/media_resource_loader_bridge_factory.cc
index 03684c8..0c3d6ab 100644
--- a/webkit/glue/media/media_resource_loader_bridge_factory.cc
+++ b/webkit/glue/media/media_resource_loader_bridge_factory.cc
@@ -2,9 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/string_util.h"
#include "webkit/glue/media/media_resource_loader_bridge_factory.h"
+#include "base/format_macros.h"
+#include "base/string_util.h"
+
namespace {
// A constant for an unknown position.
@@ -57,12 +59,12 @@ const std::string MediaResourceLoaderBridgeFactory::GenerateHeaders (
if (first_byte_position > kPositionNotSpecified &&
last_byte_position > kPositionNotSpecified) {
if (first_byte_position <= last_byte_position) {
- header = StringPrintf("Range: bytes=%lld-%lld",
+ header = StringPrintf("Range: bytes=%" PRId64 "-%" PRId64,
first_byte_position,
last_byte_position);
}
} else if (first_byte_position > kPositionNotSpecified) {
- header = StringPrintf("Range: bytes=%lld-", first_byte_position);
+ header = StringPrintf("Range: bytes=%" PRId64 "-", first_byte_position);
} else if (last_byte_position > kPositionNotSpecified) {
NOTIMPLEMENTED() << "Suffix range not implemented";
}