From 14f0ea85fde9cb50f55b3470fed0aab2ce921e2d Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Thu, 5 Sep 2024 14:11:31 +0200 Subject: [PATCH] fixup! refactor: modernize bulksupport allowlist --- src/controllers/bulk/bulkcontroller.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/controllers/bulk/bulkcontroller.cpp b/src/controllers/bulk/bulkcontroller.cpp index ea77521efc5c..29dcdae00d25 100644 --- a/src/controllers/bulk/bulkcontroller.cpp +++ b/src/controllers/bulk/bulkcontroller.cpp @@ -150,21 +150,20 @@ int BulkController::open() { } /* Look up endpoint addresses in supported database */ - const bulk_supported_t* device = std::find( - std::begin(bulk_supported), std::end(bulk_supported), bulk_supported_t { - m_vendorId, - m_productId, - m_inEndpointAddr, - m_outEndpointAddr, -#if defined(__WINDOWS__) || defined(__APPLE__) - m_interfaceNumber, -#endif - }); + const bulk_supported_t* device = std::find_if( + std::begin(bulk_supported), std::end(bulk_supported), [this](const auto& dev) { + return dev.vendor_id == m_vendorId && dev.product_id == m_productId; + }); if (!device) { qCWarning(m_logBase) << "USB Bulk device" << getName() << "unsupported"; return -1; } + m_inEndpointAddr = device->in_epaddr; + m_outEndpointAddr = device->out_epaddr; +#if defined(__WINDOWS__) || defined(__APPLE__) + m_interfaceNumber = device->interface_number; +#endif // XXX: we should enumerate devices and match vendor, product, and serial if (m_phandle == nullptr) {