Skip to content

Commit

Permalink
win/clang: Fix all remaining -Wformat warnings.
Browse files Browse the repository at this point in the history
We recently switched from building chromium_builder_tests to building
everything, this fixes almost all warnings in the ~1000 translation units
we weren't compiling before.

No behavior change.
BUG=82385
R=scottmg@chromium.org
TBR=cpu

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

Cr-Commit-Position: refs/heads/master@{#293393}
  • Loading branch information
nico committed Sep 5, 2014
1 parent 9f8fe76 commit ea993a8
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 31 deletions.
2 changes: 1 addition & 1 deletion chrome/installer/gcapi/gcapi_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void call_statically() {
if (result_flag_off != result_flag_on)
printf("Registry key flag is not being set properly.");

printf("Static call returned result as %d and reason as %d.\n",
printf("Static call returned result as %ld and reason as %ld.\n",
result_flag_on, reason);
}

Expand Down
10 changes: 10 additions & 0 deletions cloud_print/service/service.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@
'secur32.lib',
],
},
'conditions': [
['clang==1', {
# atlapp.h contains a global "using namespace WTL;".
# TODO: Remove once cloud_print_service.cc no longer depends on
# atlapp.h, http://crbug.com/5027
'VCCLCompilerTool': {
'AdditionalOptions': ['-Wno-header-hygiene'],
},
}],
],
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion cloud_print/virtual_driver/win/install/setup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ HRESULT InstallPrinter(void) {
base::string16 port_name;
printer_info.pPortName = const_cast<LPWSTR>(kPortName);
printer_info.Attributes = PRINTER_ATTRIBUTE_DIRECT|PRINTER_ATTRIBUTE_LOCAL;
printer_info.pPrintProcessor = L"winprint";
printer_info.pPrintProcessor = const_cast<LPWSTR>(L"winprint");
HANDLE handle = AddPrinter(NULL, 2, reinterpret_cast<BYTE*>(&printer_info));
if (handle == NULL) {
HRESULT result = GetLastHResult();
Expand Down
2 changes: 1 addition & 1 deletion net/tools/dump_cache/upgrade_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ void MasterSM::DoGetKey(int bytes_read) {
void MasterSM::DoCreateEntryComplete(int result) {
std::string key(input_->buffer);
if (result != net::OK) {
printf("Skipping entry \"%s\": %d\n", key.c_str(), GetLastError());
printf("Skipping entry \"%s\": %ld\n", key.c_str(), GetLastError());
return SendGetPrevEntry();
}

Expand Down
4 changes: 2 additions & 2 deletions remoting/remoting_host_win.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@
},
'conditions': [
['clang==1', {
# atlbase.h contains a global "using namespace WTL;".
# atlapp.h contains a global "using namespace WTL;".
# TODO: Remove once remoting/host/verify_config_window_win.h no
# longer depends on atlbase.h, http://crbug.com/5027
# longer depends on atlapp.h, http://crbug.com/5027
'VCCLCompilerTool': {
'AdditionalOptions': ['-Wno-header-hygiene'],
},
Expand Down
4 changes: 2 additions & 2 deletions sandbox/win/sandbox_poc/pocdll/fs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void TryOpenFile(const wchar_t *path, FILE *output) {
wchar_t path_expanded[MAX_PATH] = {0};
DWORD size = ::ExpandEnvironmentStrings(path, path_expanded, MAX_PATH - 1);
if (!size) {
fprintf(output, "[ERROR] Cannot expand \"%S\". Error %d.\r\n", path,
fprintf(output, "[ERROR] Cannot expand \"%S\". Error %ld.\r\n", path,
::GetLastError());
}

Expand All @@ -32,7 +32,7 @@ void TryOpenFile(const wchar_t *path, FILE *output) {
file);
::CloseHandle(file);
} else {
fprintf(output, "[BLOCKED] Opening file \"%S\". Error %d.\r\n", path,
fprintf(output, "[BLOCKED] Opening file \"%S\". Error %ld.\r\n", path,
::GetLastError());
}
}
Expand Down
12 changes: 6 additions & 6 deletions sandbox/win/sandbox_poc/pocdll/handles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void POCDLL_API TestGetHandle(HANDLE log) {
// Initialize the NTAPI functions we need
HMODULE ntdll_handle = ::GetModuleHandle(L"ntdll.dll");
if (!ntdll_handle) {
fprintf(output, "[ERROR] Cannot load ntdll.dll. Error %d\r\n",
fprintf(output, "[ERROR] Cannot load ntdll.dll. Error %ld\r\n",
::GetLastError());
return;
}
Expand All @@ -33,7 +33,7 @@ void POCDLL_API TestGetHandle(HANDLE log) {
GetProcAddress(ntdll_handle, "NtQuerySystemInformation"));

if (!NtQueryObject || !NtQueryInformationFile || !NtQuerySystemInformation) {
fprintf(output, "[ERROR] Cannot load all NT functions. Error %d\r\n",
fprintf(output, "[ERROR] Cannot load all NT functions. Error %ld\r\n",
::GetLastError());
return;
}
Expand All @@ -45,7 +45,7 @@ void POCDLL_API TestGetHandle(HANDLE log) {
SystemHandleInformation, &temp_info, sizeof(temp_info),
&buffer_size);
if (!buffer_size) {
fprintf(output, "[ERROR] Get the number of handles. Error 0x%X\r\n",
fprintf(output, "[ERROR] Get the number of handles. Error 0x%lX\r\n",
status);
return;
}
Expand All @@ -56,7 +56,7 @@ void POCDLL_API TestGetHandle(HANDLE log) {
status = NtQuerySystemInformation(SystemHandleInformation, system_handles,
buffer_size, &buffer_size);
if (STATUS_SUCCESS != status) {
fprintf(output, "[ERROR] Failed to get the handle list. Error 0x%X\r\n",
fprintf(output, "[ERROR] Failed to get the handle list. Error 0x%lX\r\n",
status);
delete [] system_handles;
return;
Expand Down Expand Up @@ -152,14 +152,14 @@ void POCDLL_API TestGetHandle(HANDLE log) {
file_name_string.Buffer = file_name->FileName;
file_name_string.Length = (USHORT)file_name->FileNameLength;
file_name_string.MaximumLength = (USHORT)file_name->FileNameLength;
fprintf(output, "[GRANTED] Handle 0x%4.4X Access: 0x%8.8X "
fprintf(output, "[GRANTED] Handle 0x%4.4X Access: 0x%8.8lX "
"Type: %-13.13wZ Path: %wZ\r\n",
h,
system_handles->Information[i].GrantedAccess,
type ? &type->TypeName : NULL,
&file_name_string);
} else {
fprintf(output, "[GRANTED] Handle 0x%4.4X Access: 0x%8.8X "
fprintf(output, "[GRANTED] Handle 0x%4.4X Access: 0x%8.8lX "
"Type: %-13.13wZ Path: %wZ\r\n",
h,
system_handles->Information[i].GrantedAccess,
Expand Down
10 changes: 5 additions & 5 deletions sandbox/win/sandbox_poc/pocdll/invasive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ void POCDLL_API TestThreadBombing(HANDLE log) {
0, // No creation flags
&tid);
if (thread) {
fprintf(output, "[GRANTED] Creating thread with tid 0x%X\r\n", tid);
fprintf(output, "[GRANTED] Creating thread with tid 0x%lX\r\n", tid);
::CloseHandle(thread);
number_errors = 0;
} else {
fprintf(output, "[BLOCKED] Creating thread. Error %d\r\n",
fprintf(output, "[BLOCKED] Creating thread. Error %ld\r\n",
::GetLastError());
number_errors++;
}
Expand Down Expand Up @@ -90,10 +90,10 @@ void POCDLL_API TestTakeAllCpu(HANDLE log) {
::SetThreadAffinityMask(thread, affinity_mask);

if (::SetThreadPriority(thread, REALTIME_PRIORITY_CLASS)) {
fprintf(output, "[GRANTED] Set thread(%d) priority to Realtime\r\n",
fprintf(output, "[GRANTED] Set thread(%ld) priority to Realtime\r\n",
tid);
} else {
fprintf(output, "[BLOCKED] Set thread(%d) priority to Realtime\r\n",
fprintf(output, "[BLOCKED] Set thread(%ld) priority to Realtime\r\n",
tid);
}

Expand All @@ -103,7 +103,7 @@ void POCDLL_API TestTakeAllCpu(HANDLE log) {
system_mask = system_mask >> 1;
}
} else {
fprintf(output, "[ERROR] Cannot get affinity mask. Error %d\r\n",
fprintf(output, "[ERROR] Cannot get affinity mask. Error %ld\r\n",
::GetLastError());
}
}
Expand Down
16 changes: 8 additions & 8 deletions sandbox/win/sandbox_poc/pocdll/processes_and_threads.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void POCDLL_API TestProcesses(HANDLE log) {
HANDLE snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
if (INVALID_HANDLE_VALUE == snapshot) {
fprintf(output, "[BLOCKED] Cannot list all processes on the system. "
"Error %d\r\n", ::GetLastError());
"Error %ld\r\n", ::GetLastError());
return;
}

Expand All @@ -31,13 +31,13 @@ void POCDLL_API TestProcesses(HANDLE log) {
FALSE, // Do not inherit handle.
process_entry.th32ProcessID);
if (NULL == process) {
fprintf(output, "[BLOCKED] Found process %S:%d but cannot open it. "
"Error %d\r\n",
fprintf(output, "[BLOCKED] Found process %S:%ld but cannot open it. "
"Error %ld\r\n",
process_entry.szExeFile,
process_entry.th32ProcessID,
::GetLastError());
} else {
fprintf(output, "[GRANTED] Found process %S:%d and open succeeded.\r\n",
fprintf(output, "[GRANTED] Found process %S:%ld and open succeeded.\r\n",
process_entry.szExeFile, process_entry.th32ProcessID);
::CloseHandle(process);
}
Expand All @@ -47,7 +47,7 @@ void POCDLL_API TestProcesses(HANDLE log) {

DWORD err_code = ::GetLastError();
if (ERROR_NO_MORE_FILES != err_code) {
fprintf(output, "[ERROR] Error %d while looking at the processes on "
fprintf(output, "[ERROR] Error %ld while looking at the processes on "
"the system\r\n", err_code);
}

Expand All @@ -61,7 +61,7 @@ void POCDLL_API TestThreads(HANDLE log) {
HANDLE snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, NULL);
if (INVALID_HANDLE_VALUE == snapshot) {
fprintf(output, "[BLOCKED] Cannot list all threads on the system. "
"Error %d\r\n", ::GetLastError());
"Error %ld\r\n", ::GetLastError());
return;
}

Expand All @@ -80,7 +80,7 @@ void POCDLL_API TestThreads(HANDLE log) {
nb_failure++;
} else {
nb_success++;
fprintf(output, "[GRANTED] Found thread %d:%d and able to open it.\r\n",
fprintf(output, "[GRANTED] Found thread %ld:%ld and able to open it.\r\n",
thread_entry.th32OwnerProcessID,
thread_entry.th32ThreadID);
::CloseHandle(thread);
Expand All @@ -91,7 +91,7 @@ void POCDLL_API TestThreads(HANDLE log) {

DWORD err_code = ::GetLastError();
if (ERROR_NO_MORE_FILES != err_code) {
fprintf(output, "[ERROR] Error %d while looking at the processes on "
fprintf(output, "[ERROR] Error %ld while looking at the processes on "
"the system\r\n", err_code);
}

Expand Down
4 changes: 2 additions & 2 deletions sandbox/win/sandbox_poc/pocdll/spyware.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void POCDLL_API TestSpyKeys(HANDLE log) {
fprintf(output, "[GRANTED] successfully registered hotkey\r\n");
UnregisterHotKey(NULL, 1);
} else {
fprintf(output, "[BLOCKED] Failed to register hotkey. Error = %d\r\n",
fprintf(output, "[BLOCKED] Failed to register hotkey. Error = %ld\r\n",
::GetLastError());
}

Expand Down Expand Up @@ -63,6 +63,6 @@ void POCDLL_API TestSpyScreen(HANDLE log) {
}
}

fprintf(output, "[BLOCKED] Read pixel on screen. Error = %d\r\n",
fprintf(output, "[BLOCKED] Read pixel on screen. Error = %ld\r\n",
::GetLastError());
}
6 changes: 3 additions & 3 deletions tools/win/static_initializers/static_initializers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static bool LoadDataFromPdb(const wchar_t* filename,
(void**)source);

if (FAILED(hr)) {
printf("CoCreateInstance failed - HRESULT = %08X\n", hr);
printf("CoCreateInstance failed - HRESULT = %08lX\n", hr);
return false;
}

Expand All @@ -36,15 +36,15 @@ static bool LoadDataFromPdb(const wchar_t* filename,
// Open and prepare the debug data associated with the executable.
hr = (*source)->loadDataForExe(filename, search_path, NULL);
if (FAILED(hr)) {
printf("loadDataForExe failed - HRESULT = %08X\n", hr);
printf("loadDataForExe failed - HRESULT = %08lX\n", hr);
return false;
}

// Open a session for querying symbols.
hr = (*source)->openSession(session);

if (FAILED(hr)) {
printf("openSession failed - HRESULT = %08X\n", hr);
printf("openSession failed - HRESULT = %08lX\n", hr);
return false;
}

Expand Down

0 comments on commit ea993a8

Please sign in to comment.