This is an automated email from the ASF dual-hosted git repository.

szaszm pushed a commit to branch MINIFICPP-1507
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git

commit ea2b397fc5d4d45888194649f8fbe233655c5a9c
Author: Marton Szasz <[email protected]>
AuthorDate: Thu Mar 25 12:20:49 2021 +0100

    mqtt: defer casting read result to int
---
 extensions/mqtt/processors/PublishMQTT.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/extensions/mqtt/processors/PublishMQTT.h 
b/extensions/mqtt/processors/PublishMQTT.h
index 745246f..164ade0 100644
--- a/extensions/mqtt/processors/PublishMQTT.h
+++ b/extensions/mqtt/processors/PublishMQTT.h
@@ -87,15 +87,15 @@ class PublishMQTT : public 
processors::AbstractMQTTProcessor {
       status_ = 0;
       while (read_size_ < flow_size_) {
         // MQTTClient_message::payloadlen is int, so we can't handle 2GB+
-        int readRet = static_cast<int>(stream->read(&buffer[0], 
max_seg_size_));
-        if (readRet < 0) {
+        const auto readRet = stream->read(&buffer[0], max_seg_size_);
+        if (io::isError(readRet)) {
           status_ = -1;
           return gsl::narrow<int64_t>(read_size_);
         }
         if (readRet > 0) {
           MQTTClient_message pubmsg = MQTTClient_message_initializer;
           pubmsg.payload = &buffer[0];
-          pubmsg.payloadlen = readRet;
+          pubmsg.payloadlen = gsl::narrow<int>(readRet);
           pubmsg.qos = qos_;
           pubmsg.retained = retain_;
           if (MQTTClient_publishMessage(client_, key_.c_str(), &pubmsg, 
&token_) != MQTTCLIENT_SUCCESS) {

Reply via email to