summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Plate <jplate@google.com>2021-06-30 21:08:59 +0100
committerGitHub <noreply@github.com>2021-06-30 13:08:59 -0700
commit2f24758e5aa9c5510059aa38d4d06463da586369 (patch)
treeb1cc397c29c9196504e52d32ee172ad7910ef415
parent99dec4514bf18f8079f5560468dbb84ca7c3a523 (diff)
downloadOpenCL-ICD-Loader-2f24758e5aa9c5510059aa38d4d06463da586369.tar.gz
OpenCL-ICD-Loader-2f24758e5aa9c5510059aa38d4d06463da586369.tar.bz2
OpenCL-ICD-Loader-2f24758e5aa9c5510059aa38d4d06463da586369.zip
Fix compiler warnings (#148)
* Fix compiler warnings * Define and use printf format macros for DWORD and ULONG. Co-authored-by: Brice Videau <bvideau@anl.gov>
-rw-r--r--loader/windows/icd_windows.c4
-rw-r--r--loader/windows/icd_windows.h12
-rw-r--r--loader/windows/icd_windows_dxgk.c2
-rw-r--r--loader/windows/icd_windows_hkr.c32
4 files changed, 31 insertions, 19 deletions
diff --git a/loader/windows/icd_windows.c b/loader/windows/icd_windows.c
index 4df109a..852dd0e 100644
--- a/loader/windows/icd_windows.c
+++ b/loader/windows/icd_windows.c
@@ -151,7 +151,7 @@ BOOL CALLBACK khrIcdOsVendorsEnumerate(PINIT_ONCE InitOnce, PVOID Parameter, PVO
DWORD dwValueSize = sizeof(dwValue);
// read the value name
- KHR_ICD_TRACE("Reading value %d...\n", dwIndex);
+ KHR_ICD_TRACE("Reading value %"PRIuDW"...\n", dwIndex);
result = RegEnumValueA(
platformsKey,
dwIndex,
@@ -164,7 +164,7 @@ BOOL CALLBACK khrIcdOsVendorsEnumerate(PINIT_ONCE InitOnce, PVOID Parameter, PVO
// if RegEnumKeyEx fails, we are done with the enumeration
if (ERROR_SUCCESS != result)
{
- KHR_ICD_TRACE("Failed to read value %d, done reading key.\n", dwIndex);
+ KHR_ICD_TRACE("Failed to read value %"PRIuDW", done reading key.\n", dwIndex);
break;
}
KHR_ICD_TRACE("Value %s found...\n", cszLibraryName);
diff --git a/loader/windows/icd_windows.h b/loader/windows/icd_windows.h
index 2a283d3..c25b13f 100644
--- a/loader/windows/icd_windows.h
+++ b/loader/windows/icd_windows.h
@@ -19,6 +19,18 @@
#include <stdbool.h>
#include <windows.h>
+#ifdef _LP64
+#define PRIDW_PREFIX
+#define PRIUL_PREFIX
+#else
+#define PRIDW_PREFIX "l"
+#define PRIUL_PREFIX "l"
+#endif
+#define PRIuDW PRIDW_PREFIX "u"
+#define PRIxDW PRIDW_PREFIX "x"
+#define PRIuUL PRIUL_PREFIX "u"
+#define PRIxUL PRIUL_PREFIX "x"
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/loader/windows/icd_windows_dxgk.c b/loader/windows/icd_windows_dxgk.c
index 6f1568e..5dc985c 100644
--- a/loader/windows/icd_windows_dxgk.c
+++ b/loader/windows/icd_windows_dxgk.c
@@ -155,7 +155,7 @@ bool khrIcdOsVendorsEnumerateDXGK(void)
ret |= adapterAdd(cszLibraryName, EnumAdapters.adapters[AdapterIndex].luid);
}
}
- else if (status == STATUS_INVALID_PARAMETER)
+ else if (status == (NTSTATUS)STATUS_INVALID_PARAMETER)
{
free(pQueryBuffer);
goto out;
diff --git a/loader/windows/icd_windows_hkr.c b/loader/windows/icd_windows_hkr.c
index 58d5c0c..96176ab 100644
--- a/loader/windows/icd_windows_hkr.c
+++ b/loader/windows/icd_windows_hkr.c
@@ -90,7 +90,7 @@ static bool ReadOpenCLKey(DEVINST dnDevNode)
if (CR_SUCCESS != ret)
{
- KHR_ICD_TRACE("Failed with ret 0x%x\n", ret);
+ KHR_ICD_TRACE("Failed with ret 0x%"PRIxDW"\n", ret);
goto out;
}
else
@@ -105,14 +105,14 @@ static bool ReadOpenCLKey(DEVINST dnDevNode)
if (ERROR_SUCCESS != result)
{
- KHR_ICD_TRACE("Failed to open sub key 0x%x\n", result);
+ KHR_ICD_TRACE("Failed to open sub key 0x%"PRIxDW"\n", result);
goto out;
}
cszOclPath = malloc(dwOclPathSize);
if (NULL == cszOclPath)
{
- KHR_ICD_TRACE("Failed to allocate %u bytes for registry value\n", dwOclPathSize);
+ KHR_ICD_TRACE("Failed to allocate %"PRIuDW" bytes for registry value\n", dwOclPathSize);
goto out;
}
@@ -125,7 +125,7 @@ static bool ReadOpenCLKey(DEVINST dnDevNode)
&dwOclPathSize);
if (ERROR_SUCCESS != result)
{
- KHR_ICD_TRACE("Failed to open sub key 0x%x\n", result);
+ KHR_ICD_TRACE("Failed to open sub key 0x%"PRIxDW"\n", result);
goto out;
}
@@ -137,7 +137,7 @@ static bool ReadOpenCLKey(DEVINST dnDevNode)
}
else
{
- KHR_ICD_TRACE("Unexpected registry entry 0x%x! continuing\n", dwLibraryNameType);
+ KHR_ICD_TRACE("Unexpected registry entry 0x%"PRIxDW"! continuing\n", dwLibraryNameType);
goto out;
}
}
@@ -155,7 +155,7 @@ out:
result = RegCloseKey(hkey);
if (ERROR_SUCCESS != result)
{
- KHR_ICD_TRACE("WARNING: failed to close hkey 0x%x\n", result);
+ KHR_ICD_TRACE("WARNING: failed to close hkey 0x%"PRIxDW"\n", result);
}
}
@@ -176,7 +176,7 @@ static DeviceProbeResult ProbeDevice(DEVINST devnode)
if (CR_SUCCESS != ret)
{
- KHR_ICD_TRACE(" WARNING: failed to probe the status of the device 0x%x\n", ret);
+ KHR_ICD_TRACE(" WARNING: failed to probe the status of the device 0x%"PRIxDW"\n", ret);
return ProbeFailure;
}
@@ -194,7 +194,7 @@ static DeviceProbeResult ProbeDevice(DEVINST devnode)
if (((ulStatus & DN_HAS_PROBLEM) && ulProblem == CM_PROB_NEED_RESTART) ||
ulStatus & DN_NEED_RESTART)
{
- KHR_ICD_TRACE(" WARNING: device is pending reboot (0x%x), skipping...\n", ulStatus);
+ KHR_ICD_TRACE(" WARNING: device is pending reboot (0x%" PRIxUL "), skipping...\n", ulStatus);
return PendingReboot;
}
@@ -239,7 +239,7 @@ bool khrIcdOsVendorsEnumerateHKR(void)
if (CR_SUCCESS != ret)
{
- KHR_ICD_TRACE("CM_Get_Device_ID_List_size failed with 0x%x\n", ret);
+ KHR_ICD_TRACE("CM_Get_Device_ID_List_size failed with 0x%"PRIxDW"\n", ret);
break;
}
@@ -251,7 +251,7 @@ bool khrIcdOsVendorsEnumerateHKR(void)
deviceIdList = malloc(szBuffer * sizeof(wchar_t));
if (NULL == deviceIdList)
{
- KHR_ICD_TRACE("Failed to allocate %u bytes for device ID strings\n", szBuffer);
+ KHR_ICD_TRACE("Failed to allocate %" PRIuUL " bytes for device ID strings\n", szBuffer);
break;
}
@@ -263,7 +263,7 @@ bool khrIcdOsVendorsEnumerateHKR(void)
if (CR_SUCCESS != ret)
{
- KHR_ICD_TRACE("CM_Get_Device_ID_List failed with 0x%x\n", ret);
+ KHR_ICD_TRACE("CM_Get_Device_ID_List failed with 0x%"PRIxDW"\n", ret);
KHR_SAFE_RELEASE(deviceIdList);
}
} while (CR_BUFFER_SMALL == ret);
@@ -282,11 +282,11 @@ bool khrIcdOsVendorsEnumerateHKR(void)
ret = CM_Locate_DevNodeW(&devinst, deviceId, 0);
if (CR_SUCCESS == ret)
{
- KHR_ICD_TRACE(" devinst: %d\n", devinst);
+ KHR_ICD_TRACE(" devinst: %lu\n", devinst);
}
else
{
- KHR_ICD_TRACE("CM_Locate_DevNode failed with 0x%x\n", ret);
+ KHR_ICD_TRACE("CM_Locate_DevNode failed with 0x%"PRIxDW"\n", ret);
continue;
}
@@ -311,7 +311,7 @@ bool khrIcdOsVendorsEnumerateHKR(void)
if (CR_SUCCESS != ret)
{
- KHR_ICD_TRACE(" CM_Get_Child returned 0x%x, skipping children...\n", ret);
+ KHR_ICD_TRACE(" CM_Get_Child returned 0x%"PRIxDW", skipping children...\n", ret);
}
else
{
@@ -321,7 +321,7 @@ bool khrIcdOsVendorsEnumerateHKR(void)
GUID guid;
ULONG szGuid = sizeof(guid);
- KHR_ICD_TRACE(" devchild: %d\n", devchild);
+ KHR_ICD_TRACE(" devchild: %lu\n", devchild);
ret = CM_Get_Device_IDW(
devchild,
deviceInstanceID,
@@ -330,7 +330,7 @@ bool khrIcdOsVendorsEnumerateHKR(void)
if (CR_SUCCESS != ret)
{
- KHR_ICD_TRACE(" CM_Get_Device_ID returned 0x%x, skipping device...\n", ret);
+ KHR_ICD_TRACE(" CM_Get_Device_ID returned 0x%"PRIxDW", skipping device...\n", ret);
continue;
}
else