From f9bd4f7b366dc40b4d0df7859528e3773e23f452 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Mon, 2 Oct 2023 20:10:16 +0900 Subject: [PATCH] AP_Mount: Xacti get_param_name_str returns empty string on failure --- libraries/AP_Mount/AP_Mount_Xacti.cpp | 10 ++-------- libraries/AP_Mount/AP_Mount_Xacti.h | 1 + 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/libraries/AP_Mount/AP_Mount_Xacti.cpp b/libraries/AP_Mount/AP_Mount_Xacti.cpp index 1d4916681e0249..b9738404d1e0da 100644 --- a/libraries/AP_Mount/AP_Mount_Xacti.cpp +++ b/libraries/AP_Mount/AP_Mount_Xacti.cpp @@ -569,12 +569,13 @@ void AP_Mount_Xacti::handle_param_save_response(AP_UAVCAN* ap_dronecan, const ui } // get parameter name for a particular param enum value +// returns an empty string if not found (which should never happen) const char* AP_Mount_Xacti::get_param_name_str(Param param) const { // check to avoid reading beyond end of array. This should never happen if ((uint8_t)param > ARRAY_SIZE(_param_names)) { INTERNAL_ERROR(AP_InternalError::error_t::invalid_arg_or_result); - return nullptr; + return ""; } return _param_names[(uint8_t)param]; } @@ -619,10 +620,6 @@ bool AP_Mount_Xacti::get_param_string(Param param) // convert param to string const char* param_name_str = get_param_name_str(param); - if (param_name_str == nullptr) { - return false; - } - if (_detected_modules[_instance].ap_dronecan->get_parameter_on_node(_detected_modules[_instance].node_id, param_name_str, ¶m_string_cb)) { last_send_getset_param_ms = AP_HAL::millis(); return true; @@ -641,9 +638,6 @@ bool AP_Mount_Xacti::process_set_param_int32_queue() if (_set_param_int32_queue->pop(param_to_set)) { // convert param to string const char* param_name_str = get_param_name_str(param_to_set.param); - if (param_name_str == nullptr) { - return false; - } if (_detected_modules[_instance].ap_dronecan->set_parameter_on_node(_detected_modules[_instance].node_id, param_name_str, param_to_set.value, ¶m_int_cb)) { last_send_getset_param_ms = AP_HAL::millis(); return true; diff --git a/libraries/AP_Mount/AP_Mount_Xacti.h b/libraries/AP_Mount/AP_Mount_Xacti.h index e742097519dd0d..97a48f87859c9c 100644 --- a/libraries/AP_Mount/AP_Mount_Xacti.h +++ b/libraries/AP_Mount/AP_Mount_Xacti.h @@ -132,6 +132,7 @@ class AP_Mount_Xacti : public AP_Mount_Backend static const char* _param_names[]; // array of Xacti parameter strings // get parameter name for a particular param enum value + // returns an empty string if not found (which should never happen) const char* get_param_name_str(Param param) const; // helper function to get and set parameters