[Openmp-commits] [PATCH] D137747: [openmp] [test] Fix warnings about printf format mismatches on Windows

Martin Storsjö via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Nov 9 14:27:50 PST 2022


mstorsjo created this revision.
mstorsjo added reviewers: AndreyChurbanov, JonChesterfield, natgla.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.
Herald added a project: OpenMP.

This fixes warnings like this:

  openmp/runtime/test/omp_testsuite.h:107:60: warning: format specifies type 'unsigned int' but the argument has type 'DWORD' (aka 'unsigned long') [-Wformat]
      fprintf(stderr, "CreateThread() failed: Error #%u.\n", GetLastError());
                                                     ~~      ^~~~~~~~~~~~~~
                                                     %lu


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137747

Files:
  openmp/runtime/test/omp_testsuite.h


Index: openmp/runtime/test/omp_testsuite.h
===================================================================
--- openmp/runtime/test/omp_testsuite.h
+++ openmp/runtime/test/omp_testsuite.h
@@ -104,7 +104,8 @@
   info->arg = arg;
   pthread = CreateThread(NULL, 0, __thread_func_wrapper, info, 0, NULL);
   if (pthread == NULL) {
-    fprintf(stderr, "CreateThread() failed: Error #%u.\n", GetLastError());
+    fprintf(stderr, "CreateThread() failed: Error #%u.\n",
+            (unsigned) GetLastError());
     exit(1);
   }
   *thread = pthread;
@@ -116,12 +117,13 @@
   rc = WaitForSingleObject(thread, INFINITE);
   if (rc == WAIT_FAILED) {
     fprintf(stderr, "WaitForSingleObject() failed: Error #%u.\n",
-            GetLastError());
+            (unsigned) GetLastError());
     exit(1);
   }
   rc = CloseHandle(thread);
   if (rc == 0) {
-    fprintf(stderr, "CloseHandle() failed: Error #%u.\n", GetLastError());
+    fprintf(stderr, "CloseHandle() failed: Error #%u.\n",
+            (unsigned) GetLastError());
     exit(1);
   }
   return 0;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137747.474367.patch
Type: text/x-patch
Size: 1059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20221109/538e5acb/attachment.bin>


More information about the Openmp-commits mailing list