diff --git a/protocol/esta/rdm/device.cpp b/protocol/esta/rdm/device.cpp index 29d7126..df987e1 100644 --- a/protocol/esta/rdm/device.cpp +++ b/protocol/esta/rdm/device.cpp @@ -555,12 +555,10 @@ void Device::actionGetProductDetailIdList(const MsgPtr message, MsgPtr response) response->responseType = RESPONSE_TYPE_ACK; if (product_detail_list_.empty()) - { - response->appendData(PRODUCT_DETAIL_NOT_DECLARED); - return; - } - for ( uint16_t detail : product_detail_list_ ) - response->appendData(detail); + response->appendData(PRODUCT_DETAIL_NOT_DECLARED); + else + for (const auto detail : product_detail_list_) + response->appendData(detail); } @@ -575,12 +573,8 @@ void Device::actionGetDevModelDescription(const MsgPtr message, MsgPtr response) return; response->responseType = RESPONSE_TYPE_ACK; - for (size_t i = 0; i < deviceModelDescription.size(); i++) - { - if (i > 32) - break; - response->appendData(deviceModelDescription.at(i)); - } + for (size_t i = 0; i < deviceModelDescription.size() && i <= 32; i++) + response->appendData(deviceModelDescription.at(i)); } @@ -617,7 +611,7 @@ void Device::actionGetLanguage(const MsgPtr message, MsgPtr response) response->responseType = RESPONSE_TYPE_ACK; std::string label = std::string("en"); - for (char& c : label) + for (const auto c : label) response->appendData(c); } @@ -633,7 +627,7 @@ void Device::actionSetLanguage(const MsgPtr message, MsgPtr response) return; std::string s; - for ( char c : *message->data()) + for (char c : *message->data()) s += c; if (s != "en") @@ -658,12 +652,8 @@ void Device::actionGetSoftwareVersionLabel(const MsgPtr message, MsgPtr response response->responseType = RESPONSE_TYPE_ACK; std::string label = std::string(LIB_VERSION_LABEL); - for (size_t i = 0; i < label.size(); i++) - { - if (i > 32) - break; - response->appendData(label.at(i)); - } + for (size_t i = 0; i < label.size() && i <= 32; i++) + response->appendData(label.at(i)); }