[openmp] [test] Fix warnings about printf format mismatches on Windows
authorMartin Storsjö <martin@martin.st>
Tue, 8 Nov 2022 09:45:41 +0000 (11:45 +0200)
committerMartin Storsjö <martin@martin.st>
Fri, 18 Nov 2022 06:50:26 +0000 (08:50 +0200)
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
```

Differential Revision: https://reviews.llvm.org/D137747

openmp/runtime/test/omp_testsuite.h

index b1dcf8f..ef2ae20 100644 (file)
@@ -104,7 +104,8 @@ static int pthread_create(pthread_t *thread, void *attr,
   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 @@ static int pthread_join(pthread_t thread, void **retval) {
   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;