[PATCH v2] winejoystick.drv: Gracefully handle polling an unplugged device

Aric Stewart aric at codeweavers.com
Wed Mar 2 14:46:42 CST 2016



On 3/2/16 2:33 PM, Ken Thomases wrote:
> On Mar 2, 2016, at 1:46 PM, Aric Stewart <aric at codeweavers.com> wrote:
>>
>> v2: Use a Helper function instead of duplicated code
> 
> I should have caught this the first time, but:
> 
>> +static LRESULT driver_getElementValue(IOHIDDeviceRef device, IOHIDElementRef element, IOHIDValueRef *pValueRef)
>> +{
>> +    IOReturn ret;
>> +    ret = IOHIDDeviceGetValue(device, element, pValueRef);
>> +    if (ret != kIOReturnSuccess)
>> +    {
>> +        switch (ret)
>> +        {
>> +            case kIOReturnNotAttached:
>> +                return JOYERR_UNPLUGGED;
>> +            default:
>> +                ERR("IOHIDDeviceGetValue returned 0x%x\n",ret);
>> +                return JOYERR_NOCANDO;
>> +        }
>> +    }
>> +    return JOYERR_NOERROR;
>> +}
> 
> It's a bit strange to use an "if" based on ret and then a "switch" based on it, too.  You could just use the switch, right?
> 

That is strange indeed. I don't know what I was thinking either.  v3 on its way.

-aric



More information about the wine-devel mailing list