Makes topic_name a const ref

Signed-off-by: Voldivh <eloyabmfcv@gmail.com>
(cherry picked from commit df27babd11d1a655d60ce9c5a4363f79ea8d6cf5)
This commit is contained in:
Voldivh 2022-09-02 09:48:21 -05:00 committed by Mergify
parent 83df716b61
commit 28fb2bde43

View file

@ -1498,23 +1498,23 @@ static dds_entity_t create_topic(dds_entity_t pp, struct ddsi_sertopic * sertopi
return tp; return tp;
} }
void set_error_message_from_create_topic(dds_entity_t topic, std::string topic_name) void set_error_message_from_create_topic(dds_entity_t topic, const std::string & topic_name)
{ {
assert(topic < 0); assert(topic < 0);
if (DDS_RETCODE_BAD_PARAMETER == topic) { if (DDS_RETCODE_BAD_PARAMETER == topic) {
std::string error_msg = "failed to create topic [" + topic_name + const std::string error_msg = "failed to create topic [" + topic_name +
"] because the function was given invalid parameters"; "] because the function was given invalid parameters";
RMW_SET_ERROR_MSG(error_msg.c_str()); RMW_SET_ERROR_MSG(error_msg.c_str());
} else if (DDS_RETCODE_INCONSISTENT_POLICY == topic) { } else if (DDS_RETCODE_INCONSISTENT_POLICY == topic) {
std::string error_msg = "failed to create topic [" + topic_name + const std::string error_msg = "failed to create topic [" + topic_name +
"] because it's already in use in this context with incompatible QoS settings"; "] because it's already in use in this context with incompatible QoS settings";
RMW_SET_ERROR_MSG(error_msg.c_str()); RMW_SET_ERROR_MSG(error_msg.c_str());
} else if (DDS_RETCODE_PRECONDITION_NOT_MET == topic) { } else if (DDS_RETCODE_PRECONDITION_NOT_MET == topic) {
std::string error_msg = "failed to create topic [" + topic_name + const std::string error_msg = "failed to create topic [" + topic_name +
"] because it's already in use in this context with a different message type"; "] because it's already in use in this context with a different message type";
RMW_SET_ERROR_MSG(error_msg.c_str()); RMW_SET_ERROR_MSG(error_msg.c_str());
} else { } else {
std::string error_msg = "failed to create topic [" + topic_name + "] for unknown reasons"; const std::string error_msg = "failed to create topic [" + topic_name + "] for unknown reasons";
RMW_SET_ERROR_MSG(error_msg.c_str()); RMW_SET_ERROR_MSG(error_msg.c_str());
} }
} }