Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process libusb_get_device_list error #160

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ThirdParty/PSCommon/XnLib/Source/Linux/XnLinuxUSB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,12 @@ XN_C_API XnStatus xnUSBEnumerateDevices(XnUInt16 nVendorID, XnUInt16 nProductID,
libusb_device** ppDevices;
ssize_t nDeviceCount = libusb_get_device_list(g_InitData.pContext, &ppDevices);

// check for error
if (nDeviceCount < 0)
{
return (XN_STATUS_USB_ENUMERATE_FAILED);
}

// first enumeration - count
XnUInt32 nCount = 0;

Expand Down Expand Up @@ -763,6 +769,12 @@ XN_C_API XnStatus xnUSBOpenDeviceByPath(const XnUSBConnectionString strDevicePat
libusb_device** ppDevices;
ssize_t nDeviceCount = libusb_get_device_list(g_InitData.pContext, &ppDevices);

// check for error
if (nDeviceCount < 0)
{
return (XN_STATUS_USB_ENUMERATE_FAILED);
}

libusb_device* pRequestedDevice = NULL;

for (ssize_t i = 0; i < nDeviceCount; ++i)
Expand Down