do not assign in conditional statements

This commit is contained in:
Shawn Hoffman
2017-06-07 04:42:41 -07:00
parent 50f34f8b05
commit 9357cee2ef
6 changed files with 30 additions and 26 deletions

View File

@ -266,27 +266,26 @@ static bool CheckDeviceAccess(libusb_device* device)
}
return false;
}
else if ((ret = libusb_kernel_driver_active(s_handle, 0)) == 1)
else
{
if ((ret = libusb_detach_kernel_driver(s_handle, 0)) && ret != LIBUSB_ERROR_NOT_SUPPORTED)
ret = libusb_kernel_driver_active(s_handle, 0);
if (ret == 1)
{
ERROR_LOG(SERIALINTERFACE, "libusb_detach_kernel_driver failed with error: %d", ret);
ret = libusb_detach_kernel_driver(s_handle, 0);
if (ret != 0 && ret != LIBUSB_ERROR_NOT_SUPPORTED)
ERROR_LOG(SERIALINTERFACE, "libusb_detach_kernel_driver failed with error: %d", ret);
}
}
// this split is needed so that we don't avoid claiming the interface when
// detaching the kernel driver is successful
if (ret != 0 && ret != LIBUSB_ERROR_NOT_SUPPORTED)
{
return false;
}
else if ((ret = libusb_claim_interface(s_handle, 0)))
{
ret = libusb_claim_interface(s_handle, 0);
if (ret)
ERROR_LOG(SERIALINTERFACE, "libusb_claim_interface failed with error: %d", ret);
}
else
{
return true;
}
}
return false;
}