From e5fc676562b16bb68876d7f1f813f562b4a6c11f Mon Sep 17 00:00:00 2001 From: Diego Lopez Recas Date: Tue, 28 Jan 2025 14:20:57 +0100 Subject: [PATCH] Fix logic to query the number of available devices For the riscv mux target, GetDeviceInfos always returned 1 when called with device_infos_length = 0 and out_device_infos = nullptr to query the number of available devices, regardless of the actual number of devices detected in the system. This fixes it by always returning the number of available devices in the system, but still only filling the provided vector up to its own capacity. --- modules/mux/targets/riscv/source/device_info.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/mux/targets/riscv/source/device_info.cpp b/modules/mux/targets/riscv/source/device_info.cpp index 65ed38ce6..159eaede8 100644 --- a/modules/mux/targets/riscv/source/device_info.cpp +++ b/modules/mux/targets/riscv/source/device_info.cpp @@ -199,15 +199,11 @@ static mux_result_t GetDeviceInfos(uint32_t device_types, } // copy out the device info pointer - if (out_device_infos) { + if (out_device_infos && (num_infos_out < device_infos_length)) { out_device_infos[num_infos_out] = static_cast(&info); } // advance to next device info ++num_infos_out; - if (num_infos_out >= device_infos_length) { - // no more space so terminate - break; - } } // return the number of infos that we have if (out_device_infos_length) {