Now we clamp the list to 2 and make count to 0 to avoid leaks + adding loggin

This commit is contained in:
Dmugetsu 2025-05-02 14:16:25 -06:00 committed by Dmugetsu
parent 0763601d35
commit 5a1c420b2c

View File

@ -44,18 +44,16 @@ void PS4_SYSV_ABI sceUsbdExit() {
s64 PS4_SYSV_ABI sceUsbdGetDeviceList(SceUsbdDevice*** list) {
LOG_DEBUG(Lib_Usbd, "called");
static ssize_t last_count = -1;
ssize_t count = libusb_get_device_list(g_libusb_context, list);
if (count <= 0)
if (count < 0)
return libusb_to_orbis_error((int)count);
if (count != last_count) {
LOG_INFO(Lib_Usbd, "Found {} USB devices", count);
last_count = count;
}
if (count > 2)
LOG_WARNING(Lib_Usbd, "Too Many USB Devices Connected");
libusb_unref_device((*list)[2]);
count = 0;
return ORBIS_OK;
return libusb_to_orbis_error((int)count);
}
void PS4_SYSV_ABI sceUsbdFreeDeviceList(SceUsbdDevice** list, s32 unref_devices) {