Revert "Merge branch 'master' into master"

This reverts commit 97f0eb551154ac28decc89f546eb9f4082948887, reversing
changes made to 98ca71fb9f8484f1cd1999f55224bf9e8d18693b.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1cf4013..a0da4d3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -84,7 +84,6 @@
     # only required in rare cases.
     if (DEFINED ENV{DXSDK_DIR} AND NOT (MINGW OR MSYS OR CYGWIN))
         include_directories ($ENV{DXSDK_DIR}/Include)
-        include_directories ($ENV{WDK}/km)
     endif ()
 else ()
     # By default don't include OpenCL 3.0 symbol definitions (i.e. comment them
@@ -113,7 +112,6 @@
 target_include_directories(OpenCL SYSTEM PUBLIC ${OPENCL_ICD_LOADER_HEADERS_DIR})
 
 if (WIN32)
-
     target_link_libraries (OpenCL cfgmgr32.lib runtimeobject.lib)
 
     option (OPENCL_ICD_LOADER_DISABLE_OPENCLON12 "Disable support for OpenCLOn12. Support for OpenCLOn12 should only be disabled when building an import lib to link with, and must be enabled when building an ICD loader for distribution!" OFF)
diff --git a/loader/icd.h b/loader/icd.h
index fc6f819..34751e9 100644
--- a/loader/icd.h
+++ b/loader/icd.h
@@ -122,11 +122,6 @@
     const cl_context_properties *properties, 
     cl_platform_id *outPlatform);
 
-// translate device type to platform
-void khrIcdDeviceTypeGetPlatform(
-    cl_device_type device_type,
-    cl_platform_id *outPlatform);
-
 // internal tracing macros
 #if 0
     #include <stdio.h>
diff --git a/loader/windows/OpenCL.rc b/loader/windows/OpenCL.rc
index a0f2084..3353fd4 100644
--- a/loader/windows/OpenCL.rc
+++ b/loader/windows/OpenCL.rc
@@ -32,13 +32,8 @@
     OPENCL_ICD_LOADER_TOSTRING(OPENCL_ICD_LOADER_VERSION_REV)
 
 VS_VERSION_INFO VERSIONINFO
-<<<<<<< HEAD
-FILEVERSION    2,2,2,0
-PRODUCTVERSION 2,2,2,0
-=======
 FILEVERSION    OPENCL_ICD_LOADER_VERSION_MAJOR,OPENCL_ICD_LOADER_VERSION_MINOR,OPENCL_ICD_LOADER_VERSION_REV,0
 PRODUCTVERSION OPENCL_ICD_LOADER_VERSION_MAJOR,OPENCL_ICD_LOADER_VERSION_MINOR,OPENCL_ICD_LOADER_VERSION_REV,0
->>>>>>> KhronosGroup-master
 FILETYPE       VFT_DLL
 
 BEGIN
diff --git a/loader/windows/icd_windows.c b/loader/windows/icd_windows.c
index da884f6..25f1b9b 100644
--- a/loader/windows/icd_windows.c
+++ b/loader/windows/icd_windows.c
@@ -22,6 +22,7 @@
 #include "icd_windows_dxgk.h"
 #include "icd_windows_apppackage.h"
 #include <stdio.h>
+#include <windows.h>
 #include <winreg.h>
 
 #include <initguid.h>
@@ -44,7 +45,7 @@
 
 BOOL adapterAdd(const char* szName, LUID luid)
 {
-    BOOL result = TRUE; 
+    BOOL result = TRUE;
     if (pWinAdapterEnd == pWinAdapterCapacity)
     {
         size_t oldCapacity = pWinAdapterCapacity - pWinAdapterBegin;
@@ -54,15 +55,20 @@
             newCapacity = 1;
         }
         else if(newCapacity < UINT_MAX/2)
-	    {
+        {
             newCapacity *= 2;
         }
 
-        WinAdapter* pNewBegin = realloc(pWinAdapterBegin, newCapacity * sizeof(*pWinAdapterBegin));
+        WinAdapter* pNewBegin = malloc(newCapacity * sizeof(*pWinAdapterBegin));
         if (!pNewBegin)
             result = FALSE;
         else
         {
+            if (pWinAdapterBegin)
+            {
+                memcpy(pNewBegin, pWinAdapterBegin, oldCapacity * sizeof(*pWinAdapterBegin));
+                free(pWinAdapterBegin);
+            }
             pWinAdapterCapacity = pNewBegin + newCapacity;
             pWinAdapterEnd = pNewBegin + oldCapacity;
             pWinAdapterBegin = pNewBegin;
@@ -74,8 +80,8 @@
         pWinAdapterEnd->szName = malloc(nameLen);
         if (!pWinAdapterEnd->szName)
             result = FALSE;
-        else 
-	    {
+        else
+        {
             memcpy(pWinAdapterEnd->szName, szName, nameLen);
             pWinAdapterEnd->luid = luid;
             ++pWinAdapterEnd;
@@ -88,7 +94,6 @@
 {
     free(pWinAdapter->szName);
     pWinAdapter->szName = NULL;
-    pWinAdapter->luid = ZeroLuid;
 }
 
 /*
@@ -114,7 +119,7 @@
     {
         KHR_ICD_TRACE("Failed to load via DXGK interface on RS4, continuing\n");
         status |= khrIcdOsVendorsEnumerateHKR();
-	    if (!status)
+        if (!status)
         {
             KHR_ICD_TRACE("Failed to enumerate HKR entries, continuing\n");
         }
@@ -185,8 +190,8 @@
     {
         IDXGIFactory* pFactory = NULL;
         PFN_CREATE_DXGI_FACTORY pCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY)GetProcAddress(hDXGI, "CreateDXGIFactory");
-	    if (pCreateDXGIFactory)
-	    {
+        if (pCreateDXGIFactory)
+        {
             HRESULT hr = pCreateDXGIFactory(&IID_IDXGIFactory, &pFactory);
             if (SUCCEEDED(hr))
             {
@@ -205,11 +210,10 @@
                                 khrIcdVendorAdd(iterAdapter->szName);
                                 break;
                             }
-			            } 
+                        }
                     }
 
                     pAdapter->lpVtbl->Release(pAdapter);
-                    pAdapter->lpVtbl->Release(pAdapter);
                 }
                 pFactory->lpVtbl->Release(pFactory);
             }
diff --git a/loader/windows/icd_windows_dxgk.c b/loader/windows/icd_windows_dxgk.c
index 65e896a..6f1568e 100644
--- a/loader/windows/icd_windows_dxgk.c
+++ b/loader/windows/icd_windows_dxgk.c
@@ -33,6 +33,7 @@
 {
     bool ret = false;
     int result = 0;
+
     // Get handle to GDI Runtime
     HMODULE h = LoadLibrary("gdi32.dll");
     if (h == NULL)
@@ -41,7 +42,6 @@
     if(GetProcAddress(h, "D3DKMTSubmitPresentBltToHwQueue")) // OS Version check
     {
         LoaderEnumAdapters2 EnumAdapters;
-
         NTSTATUS status = STATUS_SUCCESS;
 
         char cszLibraryName[MAX_PATH] = { 0 };
@@ -63,7 +63,6 @@
         {
             EnumAdapters.adapter_count = 0;
             EnumAdapters.adapters = NULL;
-
             status = pEnumAdapters2(&EnumAdapters);
             if (status == STATUS_BUFFER_TOO_SMALL)
             {
@@ -83,7 +82,6 @@
             KHR_ICD_TRACE("Allocation failure for adapters buffer\n");
             goto out;
         }
-
         status = pEnumAdapters2(&EnumAdapters);
         if (!NT_SUCCESS(status))
         {
@@ -92,9 +90,7 @@
         }
         const char* cszOpenCLRegKeyName = getOpenCLRegKeyName();
         const int szOpenCLRegKeyName = (int)(strlen(cszOpenCLRegKeyName) + 1)*sizeof(cszOpenCLRegKeyName[0]);
-
         for (UINT AdapterIndex = 0; AdapterIndex < EnumAdapters.adapter_count; AdapterIndex++)
-
         {
             LoaderQueryRegistryInfo queryArgs = {0};
             LoaderQueryRegistryInfo* pQueryArgs = &queryArgs;
@@ -136,7 +132,6 @@
                     continue;
                 }
             }
-
             if (NT_SUCCESS(status) && pQueryArgs->status == LOADER_QUERY_REGISTRY_STATUS_BUFFER_OVERFLOW)
             {
                 ULONG queryBufferSize = sizeof(LoaderQueryRegistryInfo) + queryArgs.output_value_size;
diff --git a/loader/windows/icd_windows_hkr.c b/loader/windows/icd_windows_hkr.c
index cc57574..58d5c0c 100644
--- a/loader/windows/icd_windows_hkr.c
+++ b/loader/windows/icd_windows_hkr.c
@@ -17,6 +17,7 @@
  */
 
 #include "icd.h"
+#include "icd_windows_hkr.h"
 #include <windows.h>
 #include "icd_windows_dxgk.h"
 #include <cfgmgr32.h>
@@ -128,7 +129,7 @@
             goto out;
         }
 
-        if (REG_MULTI_SZ != dwLibraryNameType)
+        if (REG_SZ != dwLibraryNameType)
         {
             if (REG_MULTI_SZ == dwLibraryNameType)
             {
@@ -173,7 +174,6 @@
         devnode,
         0);
 
-    // TODO: consider extracting warning messages out of this function
     if (CR_SUCCESS != ret)
     {
         KHR_ICD_TRACE("    WARNING: failed to probe the status of the device 0x%x\n", ret);
@@ -346,8 +346,6 @@
                     &szGuid,
                     0);
 
-                KHR_ICD_ASSERT(devpropType == DEVPROP_TYPE_GUID);
-
                 if (CR_SUCCESS != ret ||
                     !IsEqualGUID(&OCL_GUID_DEVCLASS_SOFTWARECOMPONENT, &guid))
                 {
diff --git a/test/loader_test/test_buffer_object.c b/test/loader_test/test_buffer_object.c
index 1de6ddb..1710e88 100644
--- a/test/loader_test/test_buffer_object.c
+++ b/test/loader_test/test_buffer_object.c
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+
 #include <CL/cl.h>
 #include "param_struct.h"
 #include <platform/icd_test_log.h>
diff --git a/test/loader_test/test_kernel.c b/test/loader_test/test_kernel.c
index ab63932..a53e980 100644
--- a/test/loader_test/test_kernel.c
+++ b/test/loader_test/test_kernel.c
@@ -154,7 +154,7 @@
                      &event);
 
     ret_val=clEnqueueMigrateMemObjects(command_queue,
-            (cl_uint)data->num_mem_objects, 
+            data->num_mem_objects, 
             data->mem_objects,
             data->flags,
             data->num_events_in_wait_list,