szaszm commented on a change in pull request #1028:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1028#discussion_r596138026



##########
File path: libminifi/src/sitetosite/SiteToSiteClient.cpp
##########
@@ -31,47 +31,37 @@ namespace sitetosite {
 
 int SiteToSiteClient::readResponse(const std::shared_ptr<Transaction>& 
/*transaction*/, RespondCode &code, std::string &message) {
   uint8_t firstByte;
-
-  int ret = peer_->read(firstByte);
-
-  if (ret <= 0 || firstByte != CODE_SEQUENCE_VALUE_1)
+  auto ret = peer_->read(firstByte);
+  if (ret == 0 || ret == static_cast<size_t>(-1) || firstByte != 
CODE_SEQUENCE_VALUE_1)
     return -1;
 
   uint8_t secondByte;
-
   ret = peer_->read(secondByte);
-
-  if (ret <= 0 || secondByte != CODE_SEQUENCE_VALUE_2)
+  if (ret == 0 || ret == static_cast<size_t>(-1) || secondByte != 
CODE_SEQUENCE_VALUE_2)
     return -1;
 
   uint8_t thirdByte;
-
   ret = peer_->read(thirdByte);
-
-  if (ret <= 0)
-    return ret;
+  if (ret == 0 || ret == static_cast<size_t>(-1))
+    return gsl::narrow_cast<int>(ret);
 
   code = (RespondCode) thirdByte;
-
   RespondCodeContext *resCode = this->getRespondCodeContext(code);
-
-  if (resCode == NULL) {
-    // Not a valid respond code
+  if (!resCode) {
     return -1;
   }
   if (resCode->hasDescription) {
     ret = peer_->read(message);
-    if (ret <= 0)
+    if (ret != static_cast<size_t>(-1))

Review comment:
       fixed partially in 0c23d4e and finally in 46f3b0e after 
https://github.com/apache/nifi-minifi-cpp/pull/1028#discussion_r596108625




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to