Bug 1499844 - Fix win64 clang-cl -Wformat warnings. r=ted
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 23 Oct 2018 14:18:15 +0000
changeset 491014 87757f9e1d78a189f5ceb1dadd7f4520f066c049
parent 491013 3daa70ac76f606894a99371cae7312d8a93a2de5
child 491015 57e435f97c303a4e04f9d74e5eafbe89cc6acab5
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersted
bugs1499844
milestone65.0a1
Bug 1499844 - Fix win64 clang-cl -Wformat warnings. r=ted Differential Revision: https://phabricator.services.mozilla.com/D9027
build/win32/crashinject.cpp
dom/media/fake-cdm/cdm-test-output-protection.h
intl/hyphenation/hyphen/hyphen.c
testing/tools/fileid/win_fileid.cpp
testing/tools/minidumpwriter/minidumpwriter.cpp
toolkit/components/telemetry/pingsender/pingsender_win.cpp
--- a/build/win32/crashinject.cpp
+++ b/build/win32/crashinject.cpp
@@ -38,17 +38,17 @@ int main(int argc, char** argv)
   slash++;
   wcscpy(slash, L"crashinjectdll.dll");
 
   // now find our target process
   HANDLE targetProc = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION,
                                   FALSE,
                                   pid);
   if (targetProc == nullptr) {
-    fprintf(stderr, "Error %d opening target process\n", GetLastError());
+    fprintf(stderr, "Error %lu opening target process\n", GetLastError());
     return 1;
   }
 
   /*
    * This is sort of insane, but we're implementing a technique described here:
    * http://www.codeproject.com/KB/threads/winspy.aspx#section_2
    *
    * The gist is to use CreateRemoteThread to create a thread in the other
@@ -57,36 +57,36 @@ int main(int argc, char** argv)
    * is the path to the library we want to load. The library we're loading
    * will then do its dirty work inside the other process.
    */
   HMODULE hKernel32 = GetModuleHandleW(L"Kernel32");
   // allocate some memory to hold the path in the remote process
   void*   pLibRemote = VirtualAllocEx(targetProc, nullptr, sizeof(filename),
                                       MEM_COMMIT, PAGE_READWRITE);
   if (pLibRemote == nullptr) {
-    fprintf(stderr, "Error %d in VirtualAllocEx\n", GetLastError());
+    fprintf(stderr, "Error %lu in VirtualAllocEx\n", GetLastError());
     CloseHandle(targetProc);
     return 1;
   }
 
   if (!WriteProcessMemory(targetProc, pLibRemote, (void*)filename,
                           sizeof(filename), nullptr)) {
-    fprintf(stderr, "Error %d in WriteProcessMemory\n", GetLastError());
+    fprintf(stderr, "Error %lu in WriteProcessMemory\n", GetLastError());
     VirtualFreeEx(targetProc, pLibRemote, sizeof(filename), MEM_RELEASE);
     CloseHandle(targetProc);
     return 1;
   }
   // Now create a thread in the target process that will load our DLL
   HANDLE hThread = CreateRemoteThread(
                      targetProc, nullptr, 0,
                      (LPTHREAD_START_ROUTINE)GetProcAddress(hKernel32,
                                                             "LoadLibraryW"),
                      pLibRemote, 0, nullptr);
   if (hThread == nullptr) {
-    fprintf(stderr, "Error %d in CreateRemoteThread\n", GetLastError());
+    fprintf(stderr, "Error %lu in CreateRemoteThread\n", GetLastError());
     VirtualFreeEx(targetProc, pLibRemote, sizeof(filename), MEM_RELEASE);
     CloseHandle(targetProc);
     return 1;
   }
   WaitForSingleObject(hThread, INFINITE);
   // Cleanup, not that it's going to matter at this point
   CloseHandle(hThread);
   VirtualFreeEx(targetProc, pLibRemote, sizeof(filename), MEM_RELEASE);
--- a/dom/media/fake-cdm/cdm-test-output-protection.h
+++ b/dom/media/fake-cdm/cdm-test-output-protection.h
@@ -39,17 +39,17 @@ static BOOL CALLBACK EnumDisplayMonitors
   IOPMVideoOutput** opmVideoOutputArray = nullptr;
   HRESULT hr = sOPMGetVideoOutputsFromHMONITORProc(hMonitor,
                                                    OPM_VOS_OPM_SEMANTICS,
                                                    &numVideoOutputs,
                                                    &opmVideoOutputArray);
   if (S_OK != hr) {
     if ((HRESULT)0x8007001f != hr && (HRESULT)0x80070032 != hr && (HRESULT)0xc02625e5 != hr) {
       char msg[100];
-      sprintf(msg, "FAIL OPMGetVideoOutputsFromHMONITOR call failed: HRESULT=0x%08x", hr);
+      sprintf(msg, "FAIL OPMGetVideoOutputsFromHMONITOR call failed: HRESULT=0x%08lx", hr);
       failureMsgs->push_back(msg);
     }
     return true;
   }
 
   DISPLAY_DEVICEA dd;
   ZeroMemory(&dd, sizeof(dd));
   dd.cb = sizeof(dd);
@@ -61,17 +61,17 @@ static BOOL CALLBACK EnumDisplayMonitors
     OPM_RANDOM_NUMBER opmRandomNumber;
     BYTE* certificate = nullptr;
     ULONG certificateLength = 0;
     hr = opmVideoOutputArray[i]->StartInitialization(&opmRandomNumber,
                                                      &certificate,
                                                      &certificateLength);
     if (S_OK != hr) {
       char msg[100];
-      sprintf(msg, "FAIL StartInitialization call failed: HRESULT=0x%08x", hr);
+      sprintf(msg, "FAIL StartInitialization call failed: HRESULT=0x%08lx", hr);
       failureMsgs->push_back(msg);
     }
 
     if (certificate) {
       CoTaskMemFree(certificate);
     }
 
     opmVideoOutputArray[i]->Release();
--- a/intl/hyphenation/hyphen/hyphen.c
+++ b/intl/hyphenation/hyphen/hyphen.c
@@ -441,17 +441,17 @@ for (k = 0; k < 2; k++) {
     while (fgets(buf, sizeof(buf), f) != NULL) {
       
       /* discard lines that don't fit in buffer */
       if (!feof(f) && strchr(buf, '\n') == NULL) {
         int c;
         while ((c = fgetc(f)) != '\n' && c != EOF);
         /* issue warning if not a comment */
         if (buf[0] != '%') {
-          fprintf(stderr, "Warning: skipping too long pattern (more than %lu chars)\n", sizeof(buf));
+          fprintf(stderr, "Warning: skipping too long pattern (more than %zu chars)\n", sizeof(buf));
         }
         continue;
       }
       
       if (strncmp(buf, "NEXTLEVEL", 9) == 0) {
         nextlevel = 1;
         break;
       } else if (buf[0] != '%') {
--- a/testing/tools/fileid/win_fileid.cpp
+++ b/testing/tools/fileid/win_fileid.cpp
@@ -13,17 +13,17 @@ struct CV_INFO_PDB70 {
   DWORD      CvSignature;
   GUID       Signature;
   DWORD      Age;
   BYTE       PdbFileName[1];
 };
 
 void print_guid(const GUID& guid, DWORD age)
 {
-  printf("%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X%X",
+  printf("%08lX%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X%lX",
          guid.Data1, guid.Data2, guid.Data3,
          guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
          guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7],
          age);
 }
 
 int main(int argc, char** argv)
 {
--- a/testing/tools/minidumpwriter/minidumpwriter.cpp
+++ b/testing/tools/minidumpwriter/minidumpwriter.cpp
@@ -29,31 +29,31 @@ int wmain(int argc, wchar_t** argv)
     return 1;
   }
 
   wchar_t* dumpfile = argv[2];
   int rv = 1;
   HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
                                 0, pid);
   if (!hProcess) {
-    fprintf(stderr, "Couldn't get handle for %d\n", pid);
+    fprintf(stderr, "Couldn't get handle for %lu\n", pid);
     return rv;
   }
 
   HANDLE file = CreateFileW(dumpfile, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS,
                             FILE_ATTRIBUTE_NORMAL, nullptr);
   if (file == INVALID_HANDLE_VALUE) {
     fprintf(stderr, "Couldn't open dump file at %S\n", dumpfile);
     CloseHandle(hProcess);
     return rv;
   }
 
   rv = 0;
   if (!MiniDumpWriteDump(hProcess, pid, file, MiniDumpNormal,
                          nullptr, nullptr, nullptr)) {
-    fprintf(stderr, "Error 0x%X in MiniDumpWriteDump\n", GetLastError());
+    fprintf(stderr, "Error 0x%lX in MiniDumpWriteDump\n", GetLastError());
     rv = 1;
   }
 
   CloseHandle(file);
   CloseHandle(hProcess);
   return rv;
 }
--- a/toolkit/components/telemetry/pingsender/pingsender_win.cpp
+++ b/toolkit/components/telemetry/pingsender/pingsender_win.cpp
@@ -138,16 +138,16 @@ Post(const string& url, const string& pa
                      /* lpdwBufferLength */ &bufferLength,
                      /* lpdwIndex */ NULL);
   if (!rv) {
     PINGSENDER_LOG("ERROR: Could not get the HTTP status code\n");
     return false;
   }
 
   if (statusCode != 200) {
-    PINGSENDER_LOG("ERROR: Error submitting the HTTP request: code %u\n", statusCode);
+    PINGSENDER_LOG("ERROR: Error submitting the HTTP request: code %lu\n", statusCode);
     return false;
   }
 
   return rv;
 }
 
 } // namespace PingSender