From d75a985bdf68b6fa48d644ad1e285518663fa987 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 22 Jun 2023 10:51:36 +0200 Subject: [PATCH] gatt-service/hids_device: fix report lookup functions --- src/ble/gatt-service/hids_device.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ble/gatt-service/hids_device.c b/src/ble/gatt-service/hids_device.c index cbddfbef7..2d28167c2 100644 --- a/src/ble/gatt-service/hids_device.c +++ b/src/ble/gatt-service/hids_device.c @@ -103,8 +103,9 @@ static hids_device_t * hids_device_create_instance(void){ } static hids_device_report_t * hids_device_get_report_for_client_configuration_handle(hids_device_t * device, uint16_t client_configuration_handle){ - uint8_t pos = 0; - while (pos < (device->hid_input_reports_num + device->hid_output_reports_num + device->hid_feature_reports_num)){ + uint8_t pos; + uint8_t total_reports = device->hid_input_reports_num + device->hid_output_reports_num + device->hid_feature_reports_num; + for (pos = 0 ; pos < total_reports ; pos++){ if (device->hid_reports[pos].client_configuration_handle == client_configuration_handle){ return &device->hid_reports[pos]; } @@ -113,8 +114,9 @@ static hids_device_report_t * hids_device_get_report_for_client_configuration_ha } static hids_device_report_t * hids_device_get_report_for_id(hids_device_t * device, uint16_t report_id){ - uint8_t pos = 0; - while (pos < (device->hid_input_reports_num + device->hid_output_reports_num + device->hid_feature_reports_num)){ + uint8_t pos; + uint8_t total_reports = device->hid_input_reports_num + device->hid_output_reports_num + device->hid_feature_reports_num; + for (pos = 0 ; pos < total_reports ; pos++){ if (device->hid_reports[pos].id == report_id){ return &device->hid_reports[pos]; }