dinput: Give correct count of devices still to be enumerated.

Andrew Eikum aeikum at codeweavers.com
Tue Feb 7 08:57:50 CST 2017


Thanks for working on this. The logic looks good, just some small
comments in-line below.

On Sat, Feb 04, 2017 at 03:35:10PM +0200, Jetro Jormalainen wrote:
> diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c
> index 06af92f9b2..05651c9ced 100644
> --- a/dlls/dinput/dinput_main.c
> +++ b/dlls/dinput/dinput_main.c
> @@ -930,7 +930,8 @@ static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
>      LPDIRECTINPUTDEVICE8A lpdid;
>      DWORD callbackFlags;
>      int i, j;
> -
> +    int c = 0;

Please use a more descriptive variable name, like "count" or "total"
or something.

> +    for (i=0; i < c; i++)
> +    {
> +        unsigned remain = c - (i+1) + ((dwFlags & DIEDBSFL_FORCEFEEDBACK) ? 0 : sizeof(guids)/sizeof(guids[0]));

Please consistently use spaces around operators.

If you wanted to make that line a little less ugly, you could assign
"remain" before the loop and decrement it each iteration.

> +        callbackFlags = diactionformat_priorityA(lpdiActionFormat, lpdiActionFormat->dwGenre);
> +        IDirectInput_CreateDevice(iface, &didevis[i].guidInstance, &lpdid, NULL);
> +
> +        if (lpCallback(&didevis[i], lpdid, callbackFlags, remain, pvRef) == DIENUM_STOP)
> +        {
> +            HeapFree(GetProcessHeap(), 0, (void*) didevis);
> +            return DI_OK;
> +        }
> +    }
> +
> +    HeapFree(GetProcessHeap(), 0, (void*) didevis);
> +

There's no need for the explicit cast in HeapFree.

All of the above also applies to the W-version, obviously.

> +    if (!data->device_count) {
> +        data->first_remaining = dwRemaining;
> +    }
> +    ok (dwRemaining == data->first_remaining - data->device_count,
> +        "enum semantics remaining devices is wrong, expected %d, had %d",
> +        data->first_remaining - data->device_count, dwRemaining);

This ok() needs a newline at the end.

Andrew



More information about the wine-devel mailing list