[PATCH 3/5] setupapi: Fix compiler warnings when converting between pointers and integers on 64-bit systems

Hugh McMaster hugh.mcmaster at outlook.com
Tue Aug 8 21:26:48 CDT 2017


On Tuesday, 8 August 2017 9:04 PM, Alexandre Julliard wrote:
> That's only hiding the bug.

The basic problem is the use of DWORD in the following structure. On 64-bit 
systems we then see warnings about the sizeof(DWORD) vs sizeof(void *).

/* Pointed to by SP_DEVINFO_DATA's Reserved member */
struct DeviceInfo
{
    struct DeviceInfoSet *set;
    HKEY                  key;
    BOOL                  phantom;
    DWORD                 devId;
    LPWSTR                instanceId;
    struct list           interfaces;
};

There are several ways to fix the core problem. One option is to replace
the DWORD in that struct with DWORD_PTR or ULONG_PTR.
Both types are identical, with DWORD_PTR being a typedef'd ULONG_PTR.

Another option is to typedef a QWORD, and then use C preprocessing:
#ifdef _WIN64
QWORD devId;
#else
DWORD devID;
#endif

Unfortunately, however we choose to fix this part, using (multiple) casts 
will still be necessary to prevent the compiler warning about
mismatched size conversion between pointers and integers.

For example, in line 471:
>    devInfo->devId = (DWORD)devInst;
devInst is a HANDLE (i.e. void *).

Line 4027 in dlls/setupapi/devinst.c:
    struct DeviceInfo *ppdevInfo = GlobalLock((HANDLE)dnDevInst);
dnDevInst is type DEVINST, which is a typedef'd DWORD.

How do you want to proceed?

--
Hugh McMaster


More information about the wine-devel mailing list