Skip to content

Commit

Permalink
Make inttypes.h and similar macro usage C++11-friendly.
Browse files Browse the repository at this point in the history
"foo"PRIuS is a user-defined literal in C++11. Add spaces around these macros.

Likewise, L"\xab"L"c" is a user-defined literal, so insert a space in the
middle.

No functionality change.

BUG=chromium:263960
TBR=alokp@chromium.org, dmichael@chromium.org, enne@chromium.org, isherman@chromium.org, rsleevi@chromium.org, thestig@chromium.org

Review URL: https://codereview.chromium.org/20182002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213566 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
thakis@chromium.org committed Jul 25, 2013
1 parent 9747a17 commit 00c83cc
Show file tree
Hide file tree
Showing 27 changed files with 96 additions and 97 deletions.
11 changes: 3 additions & 8 deletions build/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -3133,10 +3133,7 @@
# this is worth fixing.
'-Wno-c++11-narrowing',

# This warns about code like |"0x%08"NACL_PRIxPTR| -- with C++11
# user-defined literals, this is now a string literal with a UD
# suffix. However, this is used heavily in NaCl code, so disable
# the warning for now.
# TODO(thakis): Remove, http://crbug.com/263960
'-Wno-reserved-user-defined-literal',

# Clang considers the `register` keyword as deprecated, but e.g.
Expand Down Expand Up @@ -3830,10 +3827,7 @@
# this is worth fixing.
'-Wno-c++11-narrowing',

# This warns about code like |"0x%08"NACL_PRIxPTR| -- with C++11
# user-defined literals, this is now a string literal with a UD
# suffix. However, this is used heavily in NaCl code, so disable
# the warning for now.
# TODO(thakis): Remove, http://crbug.com/263960
'-Wno-reserved-user-defined-literal',

# Don't die on dtoa code that uses a char as an array index.
Expand Down Expand Up @@ -4141,6 +4135,7 @@
'-Wno-unnamed-type-template-args',
# Match OS X clang C++11 warning settings.
'-Wno-c++11-narrowing',
# TODO(thakis): Remove, http://crbug.com/263960
'-Wno-reserved-user-defined-literal',
],
},
Expand Down
6 changes: 3 additions & 3 deletions cc/scheduler/scheduler_state_machine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ std::string SchedulerStateMachine::ToString() {
main_thread_needs_layer_textures_);
base::StringAppendF(&str, "inside_begin_frame_ = %d; ",
inside_begin_frame_);
base::StringAppendF(&str, "last_frame_time_ = %"PRId64"; ",
base::StringAppendF(&str, "last_frame_time_ = %" PRId64 "; ",
(last_begin_frame_args_.frame_time - base::TimeTicks())
.InMilliseconds());
base::StringAppendF(&str, "last_deadline_ = %"PRId64"; ",
base::StringAppendF(&str, "last_deadline_ = %" PRId64 "; ",
(last_begin_frame_args_.deadline - base::TimeTicks()).InMilliseconds());
base::StringAppendF(&str, "last_interval_ = %"PRId64"; ",
base::StringAppendF(&str, "last_interval_ = %" PRId64 "; ",
last_begin_frame_args_.interval.InMilliseconds());
base::StringAppendF(&str, "visible_ = %d; ", visible_);
base::StringAppendF(&str, "can_start_ = %d; ", can_start_);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/extension_protocols.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ net::HttpResponseHeaders* BuildHttpHeaders(
if (!last_modified_time.is_null()) {
// Hash the time and make an etag to avoid exposing the exact
// user installation time of the extension.
std::string hash = base::StringPrintf("%"PRId64"",
std::string hash = base::StringPrintf("%" PRId64,
last_modified_time.ToInternalValue());
hash = base::SHA1HashString(hash);
std::string etag;
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/safe_browsing/browser_feature_extractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static void AddNavigationFeatures(
if (redirect_chain[i].SchemeIsSecure()) {
printable_redirect = features::kSecureRedirectValue;
}
AddFeature(base::StringPrintf("%s%s[%"PRIuS"]=%s",
AddFeature(base::StringPrintf("%s%s[%" PRIuS "]=%s",
feature_prefix.c_str(),
features::kRedirect,
i,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ TEST_F(InitValueManifestTest, InitFromValueValidNameInRTL) {
// Strong RTL characters in name.
extension = LoadAndExpectSuccess("init_valid_name_strong_rtl.json");

localized_name = WideToUTF16(L"Dictionary (\x05D1\x05D2"L" Google)");
localized_name = WideToUTF16(L"Dictionary (\x05D1\x05D2" L" Google)");
base::i18n::AdjustStringForLocaleDirection(&localized_name);
EXPECT_EQ(localized_name, UTF8ToUTF16(extension->name()));

Expand Down
2 changes: 1 addition & 1 deletion chrome/test/chromedriver/server/http_response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void HttpResponse::GetData(std::string* data) const {
std::string length;
if (!GetHeader(kContentLengthHeader, &length)) {
*data += base::StringPrintf(
"%s:%"PRIuS"\r\n",
"%s:%" PRIuS "\r\n",
kContentLengthHeader, body_.length());
}
*data += "\r\n";
Expand Down
3 changes: 1 addition & 2 deletions chrome/test/webdriver/http_response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ void HttpResponse::GetData(std::string* data) const {
std::string length;
if (!GetHeader(kContentLengthHeader, &length)) {
*data += base::StringPrintf(
"%s:%"PRIuS"\r\n",
kContentLengthHeader, body_.length());
"%s:%" PRIuS "\r\n", kContentLengthHeader, body_.length());
}
*data += "\r\n";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,10 @@ TEST_F(WhitelistManagerTest, DownloadWhitelistRetry) {
for (size_t i = 0; i < arraysize(kBackoffDelaysInMs); ++i) {
DownloadWhitelist(net::HTTP_INTERNAL_SERVER_ERROR,
kDownloadWhitelistResponse);
SCOPED_TRACE(
base::StringPrintf("Testing retry %"PRIuS", expecting delay: %"PRId64,
i, kBackoffDelaysInMs[i]));
SCOPED_TRACE(base::StringPrintf("Testing retry %" PRIuS
", expecting delay: %" PRId64,
i,
kBackoffDelaysInMs[i]));
EXPECT_EQ(
kBackoffDelaysInMs[i],
whitelist_manager_->download_interval().InMillisecondsRoundedUp());
Expand Down
2 changes: 1 addition & 1 deletion content/common/content_param_traits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ bool ParamTraits<ui::Range>::Read(const Message* m,
}

void ParamTraits<ui::Range>::Log(const ui::Range& r, std::string* l) {
l->append(base::StringPrintf("(%"PRIuS", %"PRIuS")", r.start(), r.end()));
l->append(base::StringPrintf("(%" PRIuS ", %" PRIuS ")", r.start(), r.end()));
}

void ParamTraits<WebInputEventPointer>::Write(Message* m, const param_type& p) {
Expand Down
2 changes: 1 addition & 1 deletion net/test/embedded_test_server/http_response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ std::string BasicHttpResponse::ToResponseString() const {
http_reason_phrase.c_str());
base::StringAppendF(&response_builder, "Connection: close\r\n");
base::StringAppendF(&response_builder,
"Content-Length: %"PRIuS"\r\n",
"Content-Length: %" PRIuS "\r\n",
content_.size());
base::StringAppendF(&response_builder,
"Content-Type: %s\r\n",
Expand Down
6 changes: 3 additions & 3 deletions net/tools/get_server_time/get_server_time.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ int main(int argc, char* argv[]) {

fetcher->Start();
std::printf(
"Request started at %s (ticks = %"PRId64")\n",
"Request started at %s (ticks = %" PRId64 ")\n",
UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(start_time)).c_str(),
start_ticks.ToInternalValue());

Expand All @@ -285,7 +285,7 @@ int main(int argc, char* argv[]) {
const base::TimeTicks end_ticks = base::TimeTicks::Now();

std::printf(
"Request ended at %s (ticks = %"PRId64")\n",
"Request ended at %s (ticks = %" PRId64 ")\n",
UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(end_time)).c_str(),
end_ticks.ToInternalValue());

Expand All @@ -294,7 +294,7 @@ int main(int argc, char* argv[]) {
const base::TimeDelta delta_ticks = end_ticks - start_ticks;

std::printf(
"Request took %"PRId64" ticks (%.2f ms)\n",
"Request took %" PRId64 " ticks (%.2f ms)\n",
delta_ticks_internal, delta_ticks.InMillisecondsF());

const net::URLRequestStatus status = fetcher->GetStatus();
Expand Down
11 changes: 6 additions & 5 deletions ppapi/native_client/src/trusted/plugin/file_downloader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ bool FileDownloader::Open(
pp::CompletionCallback onload_callback =
callback_factory_.NewCallback(start_notify);
int32_t pp_error = url_loader_.Open(url_request, onload_callback);
PLUGIN_PRINTF(("FileDownloader::Open (pp_error=%"NACL_PRId32")\n", pp_error));
PLUGIN_PRINTF(("FileDownloader::Open (pp_error=%" NACL_PRId32 ")\n",
pp_error));
CHECK(pp_error == PP_OK_COMPLETIONPENDING);
return true;
}
Expand Down Expand Up @@ -250,17 +251,17 @@ bool FileDownloader::InitialResponseIsValid(int32_t pp_error) {
switch (url_scheme_) {
case SCHEME_CHROME_EXTENSION:
PLUGIN_PRINTF(("FileDownloader::InitialResponseIsValid (chrome-extension "
"response status_code=%"NACL_PRId32")\n", status_code_));
"response status_code=%" NACL_PRId32 ")\n", status_code_));
status_ok = (status_code_ == kExtensionUrlRequestStatusOk);
break;
case SCHEME_DATA:
PLUGIN_PRINTF(("FileDownloader::InitialResponseIsValid (data URI "
"response status_code=%"NACL_PRId32")\n", status_code_));
"response status_code=%" NACL_PRId32 ")\n", status_code_));
status_ok = (status_code_ == kDataUriRequestStatusOk);
break;
case SCHEME_OTHER:
PLUGIN_PRINTF(("FileDownloader::InitialResponseIsValid (HTTP response "
"status_code=%"NACL_PRId32")\n", status_code_));
"status_code=%" NACL_PRId32 ")\n", status_code_));
status_ok = (status_code_ == NACL_HTTP_STATUS_OK);
break;
}
Expand Down Expand Up @@ -439,7 +440,7 @@ nacl::string FileDownloader::GetResponseHeaders() const {

void FileDownloader::StreamFinishNotify(int32_t pp_error) {
PLUGIN_PRINTF((
"FileDownloader::StreamFinishNotify (pp_error=%"NACL_PRId32")\n",
"FileDownloader::StreamFinishNotify (pp_error=%" NACL_PRId32 ")\n",
pp_error));
stream_finish_callback_.RunAndClear(pp_error);
}
Expand Down
4 changes: 2 additions & 2 deletions ppapi/native_client/src/trusted/plugin/local_temp_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void LocalTempFile::Initialize() {
pp::Module::Get()->GetBrowserInterface(PPB_FILEIOTRUSTED_INTERFACE));
++next_identifier;
SNPRINTF(reinterpret_cast<char *>(identifier_), sizeof identifier_,
"%"NACL_PRIu32, next_identifier);
"%" NACL_PRIu32, next_identifier);
}

LocalTempFile::~LocalTempFile() {
Expand Down Expand Up @@ -116,7 +116,7 @@ void LocalTempFile::OpenWrite(const pp::CompletionCallback& cb) {
int32_t LocalTempFile::GetFD(int32_t pp_error,
const pp::Resource& resource,
bool is_writable) {
PLUGIN_PRINTF(("LocalTempFile::GetFD (pp_error=%"NACL_PRId32
PLUGIN_PRINTF(("LocalTempFile::GetFD (pp_error=%" NACL_PRId32
", is_writable=%d)\n", pp_error, is_writable));
if (pp_error != PP_OK) {
PLUGIN_PRINTF(("LocalTempFile::GetFD pp_error != PP_OK\n"));
Expand Down
3 changes: 2 additions & 1 deletion ppapi/native_client/src/trusted/plugin/module_ppapi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class ModulePpapi : public pp::Module {
}

virtual pp::Instance* CreateInstance(PP_Instance pp_instance) {
MODULE_PRINTF(("ModulePpapi::CreateInstance (pp_instance=%"NACL_PRId32")\n",
MODULE_PRINTF(("ModulePpapi::CreateInstance (pp_instance=%" NACL_PRId32
")\n",
pp_instance));
Plugin* plugin = Plugin::New(pp_instance);
MODULE_PRINTF(("ModulePpapi::CreateInstance (return %p)\n",
Expand Down
30 changes: 15 additions & 15 deletions ppapi/native_client/src/trusted/plugin/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ bool Plugin::NexeIsContentHandler() const {


Plugin* Plugin::New(PP_Instance pp_instance) {
PLUGIN_PRINTF(("Plugin::New (pp_instance=%"NACL_PRId32")\n", pp_instance));
PLUGIN_PRINTF(("Plugin::New (pp_instance=%" NACL_PRId32 ")\n", pp_instance));
Plugin* plugin = new Plugin(pp_instance);
PLUGIN_PRINTF(("Plugin::New (plugin=%p)\n", static_cast<void*>(plugin)));
if (plugin == NULL) {
Expand All @@ -645,7 +645,7 @@ Plugin* Plugin::New(PP_Instance pp_instance) {
// there is no need to log to JS console that there was an initialization
// failure. Note that module loading functions will log their own errors.
bool Plugin::Init(uint32_t argc, const char* argn[], const char* argv[]) {
PLUGIN_PRINTF(("Plugin::Init (argc=%"NACL_PRIu32")\n", argc));
PLUGIN_PRINTF(("Plugin::Init (argc=%" NACL_PRIu32 ")\n", argc));
HistogramEnumerateOsArch(GetSandboxISA());
init_time_ = NaClGetTimeOfDayMicroseconds();

Expand Down Expand Up @@ -740,7 +740,7 @@ Plugin::Plugin(PP_Instance pp_instance)
time_of_last_progress_event_(0),
nacl_interface_(NULL) {
PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%"
NACL_PRId32")\n", static_cast<void*>(this), pp_instance));
NACL_PRId32 ")\n", static_cast<void*>(this), pp_instance));
callback_factory_.Initialize(this);
nexe_downloader_.Initialize(this);
nacl_interface_ = GetNaClInterface();
Expand Down Expand Up @@ -844,10 +844,10 @@ void Plugin::HistogramStartupTimeMedium(const std::string& name, float dt) {
}

void Plugin::NexeFileDidOpen(int32_t pp_error) {
PLUGIN_PRINTF(("Plugin::NexeFileDidOpen (pp_error=%"NACL_PRId32")\n",
PLUGIN_PRINTF(("Plugin::NexeFileDidOpen (pp_error=%" NACL_PRId32 ")\n",
pp_error));
struct NaClFileInfo info = nexe_downloader_.GetFileInfo();
PLUGIN_PRINTF(("Plugin::NexeFileDidOpen (file_desc=%"NACL_PRId32")\n",
PLUGIN_PRINTF(("Plugin::NexeFileDidOpen (file_desc=%" NACL_PRId32 ")\n",
info.desc));
HistogramHTTPStatusCode(
is_installed_ ?
Expand Down Expand Up @@ -953,7 +953,7 @@ void Plugin::CopyCrashLogToJsConsole() {
size_t ix_start = 0;
size_t ix_end;

PLUGIN_PRINTF(("Plugin::CopyCrashLogToJsConsole: got %"NACL_PRIuS" bytes\n",
PLUGIN_PRINTF(("Plugin::CopyCrashLogToJsConsole: got %" NACL_PRIuS " bytes\n",
fatal_msg.size()));
while (nacl::string::npos != (ix_end = fatal_msg.find('\n', ix_start))) {
LogLineToConsole(this, fatal_msg.substr(ix_start, ix_end - ix_start));
Expand All @@ -965,7 +965,7 @@ void Plugin::CopyCrashLogToJsConsole() {
}

void Plugin::NexeDidCrash(int32_t pp_error) {
PLUGIN_PRINTF(("Plugin::NexeDidCrash (pp_error=%"NACL_PRId32")\n",
PLUGIN_PRINTF(("Plugin::NexeDidCrash (pp_error=%" NACL_PRId32 ")\n",
pp_error));
if (pp_error != PP_OK) {
PLUGIN_PRINTF(("Plugin::NexeDidCrash: CallOnMainThread callback with"
Expand Down Expand Up @@ -1012,7 +1012,7 @@ void Plugin::NexeDidCrash(int32_t pp_error) {
}

void Plugin::BitcodeDidTranslate(int32_t pp_error) {
PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate (pp_error=%"NACL_PRId32")\n",
PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate (pp_error=%" NACL_PRId32 ")\n",
pp_error));
if (pp_error != PP_OK) {
// Error should have been reported by pnacl. Just return.
Expand Down Expand Up @@ -1080,7 +1080,7 @@ void Plugin::ReportDeadNexe() {

void Plugin::NaClManifestBufferReady(int32_t pp_error) {
PLUGIN_PRINTF(("Plugin::NaClManifestBufferReady (pp_error=%"
NACL_PRId32")\n", pp_error));
NACL_PRId32 ")\n", pp_error));
ErrorInfo error_info;
set_manifest_url(nexe_downloader_.url());
if (pp_error != PP_OK) {
Expand Down Expand Up @@ -1117,7 +1117,7 @@ void Plugin::NaClManifestBufferReady(int32_t pp_error) {

void Plugin::NaClManifestFileDidOpen(int32_t pp_error) {
PLUGIN_PRINTF(("Plugin::NaClManifestFileDidOpen (pp_error=%"
NACL_PRId32")\n", pp_error));
NACL_PRId32 ")\n", pp_error));
HistogramTimeSmall("NaCl.Perf.StartupTime.ManifestDownload",
nexe_downloader_.TimeSinceOpenMilliseconds());
HistogramHTTPStatusCode(
Expand All @@ -1131,7 +1131,7 @@ void Plugin::NaClManifestFileDidOpen(int32_t pp_error) {
set_manifest_url(nexe_downloader_.url());
struct NaClFileInfo info = nexe_downloader_.GetFileInfo();
PLUGIN_PRINTF(("Plugin::NaClManifestFileDidOpen (file_desc=%"
NACL_PRId32")\n", info.desc));
NACL_PRId32 ")\n", info.desc));
if (pp_error != PP_OK || info.desc == NACL_NO_FILE_DESC) {
if (pp_error == PP_ERROR_ABORTED) {
ReportLoadAbort();
Expand Down Expand Up @@ -1313,7 +1313,7 @@ bool Plugin::SetManifestObject(const nacl::string& manifest_json,
void Plugin::UrlDidOpenForStreamAsFile(int32_t pp_error,
FileDownloader*& url_downloader,
PP_CompletionCallback callback) {
PLUGIN_PRINTF(("Plugin::UrlDidOpen (pp_error=%"NACL_PRId32
PLUGIN_PRINTF(("Plugin::UrlDidOpen (pp_error=%" NACL_PRId32
", url_downloader=%p)\n", pp_error,
static_cast<void*>(url_downloader)));
url_downloaders_.erase(url_downloader);
Expand Down Expand Up @@ -1513,7 +1513,7 @@ void Plugin::EnqueueProgressEvent(const char* event_type,
uint64_t total_bytes) {
PLUGIN_PRINTF(("Plugin::EnqueueProgressEvent ("
"event_type='%s', url='%s', length_computable=%d, "
"loaded=%"NACL_PRIu64", total=%"NACL_PRIu64")\n",
"loaded=%" NACL_PRIu64 ", total=%" NACL_PRIu64 ")\n",
event_type,
url.c_str(),
static_cast<int>(length_computable),
Expand Down Expand Up @@ -1541,7 +1541,7 @@ void Plugin::ReportSelLdrLoadStatus(int status) {

void Plugin::DispatchProgressEvent(int32_t result) {
PLUGIN_PRINTF(("Plugin::DispatchProgressEvent (result=%"
NACL_PRId32")\n", result));
NACL_PRId32 ")\n", result));
if (result < 0) {
return;
}
Expand All @@ -1553,7 +1553,7 @@ void Plugin::DispatchProgressEvent(int32_t result) {
progress_events_.pop();
PLUGIN_PRINTF(("Plugin::DispatchProgressEvent ("
"event_type='%s', url='%s', length_computable=%d, "
"loaded=%"NACL_PRIu64", total=%"NACL_PRIu64")\n",
"loaded=%" NACL_PRIu64 ", total=%" NACL_PRIu64 ")\n",
event->event_type(),
event->url(),
static_cast<int>(event->length_computable()),
Expand Down
Loading

0 comments on commit 00c83cc

Please sign in to comment.