lordgamez commented on code in PR #1661:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1661#discussion_r1338433725


##########
extensions/expression-language/Expression.cpp:
##########
@@ -118,21 +118,21 @@ Value resolve_user_id(const std::vector<Value> &args) {
 }
 
 Value expr_hostname(const std::vector<Value> &args) {
-  char hostname[1024];
+  std::array<char, 1024> hostname{};
   hostname[1023] = '\0';

Review Comment:
   Good points, updated in 760f6ab8125f79b5454684d6519442d725690a5c



##########
extensions/librdkafka/PublishKafka.cpp:
##########
@@ -619,7 +622,7 @@ bool PublishKafka::createNewTopic(const 
std::shared_ptr<core::ProcessContext> &c
   }
 
   // The topic takes ownership of the configuration, we must not free it
-  gsl::owner<rd_kafka_topic_t*> topic_reference = 
rd_kafka_topic_new(conn_->getConnection(), topic_name.c_str(), 
topic_conf_.release());
+  const auto topic_reference = 
gsl::owner<rd_kafka_topic_t*>(rd_kafka_topic_new(conn_->getConnection(), 
topic_name.c_str(), topic_conf_.release()));  // 
NOLINT(cppcoreguidelines-owning-memory)

Review Comment:
   It was needed due to the `conn_->getConnection()` parameter as it returned 
gsl::owner instead of a raw pointer. I changed the return type to return raw 
pointer without changing ownership in 760f6ab8125f79b5454684d6519442d725690a5c



##########
libminifi/src/core/extension/ExtensionManager.cpp:
##########
@@ -33,7 +33,7 @@ const std::shared_ptr<logging::Logger> 
ExtensionManager::logger_ = logging::Logg
 
 ExtensionManager::ExtensionManager() {
   modules_.push_back(std::make_unique<Executable>());
-  active_module_ = modules_[0].get();
+  active_module_ = modules_[0].get();  // 
NOLINT(cppcoreguidelines-prefer-member-initializer)
 }

Review Comment:
   Updated in 760f6ab8125f79b5454684d6519442d725690a5c



##########
libminifi/test/unit/FilePatternTests.cpp:
##########


Review Comment:
   Updated in 760f6ab8125f79b5454684d6519442d725690a5c



##########
extensions/opc/src/opc.cpp:
##########
@@ -465,71 +467,82 @@ std::string nodeValue2String(const NodeData& nd) {
       ret_val = std::string(reinterpret_cast<const char *>(value.data), 
value.length);
       break;
     }
-    case UA_DATATYPEKIND_BOOLEAN:
-      bool b;
+    case UA_DATATYPEKIND_BOOLEAN: {
+      bool b = false;
       memcpy(&b, nd.data.data(), sizeof(bool));
       ret_val = b ? "True" : "False";
       break;
-    case UA_DATATYPEKIND_SBYTE:
-      int8_t i8t;
+    }
+    case UA_DATATYPEKIND_SBYTE: {
+      int8_t i8t = 0;
       memcpy(&i8t, nd.data.data(), sizeof(i8t));
       ret_val = std::to_string(i8t);
       break;
-    case UA_DATATYPEKIND_BYTE:
-      uint8_t ui8t;
+    }
+    case UA_DATATYPEKIND_BYTE: {
+      uint8_t ui8t = 0;
       memcpy(&ui8t, nd.data.data(), sizeof(ui8t));
       ret_val = std::to_string(ui8t);
       break;
-    case UA_DATATYPEKIND_INT16:
-      int16_t i16t;
+    }
+    case UA_DATATYPEKIND_INT16: {
+      int16_t i16t = 0;
       memcpy(&i16t, nd.data.data(), sizeof(i16t));
       ret_val = std::to_string(i16t);
       break;
-    case UA_DATATYPEKIND_UINT16:
-      uint16_t ui16t;
+    }
+    case UA_DATATYPEKIND_UINT16: {
+      uint16_t ui16t = 0;
       memcpy(&ui16t, nd.data.data(), sizeof(ui16t));
       ret_val = std::to_string(ui16t);
       break;
-    case UA_DATATYPEKIND_INT32:
-      int32_t i32t;
+    }
+    case UA_DATATYPEKIND_INT32: {
+      int32_t i32t = 0;
       memcpy(&i32t, nd.data.data(), sizeof(i32t));
       ret_val = std::to_string(i32t);
       break;
-    case UA_DATATYPEKIND_UINT32:
-      uint32_t ui32t;
+    }
+    case UA_DATATYPEKIND_UINT32: {
+      uint32_t ui32t = 0;
       memcpy(&ui32t, nd.data.data(), sizeof(ui32t));
       ret_val = std::to_string(ui32t);
       break;
-    case UA_DATATYPEKIND_INT64:
-      int64_t i64t;
+    }
+    case UA_DATATYPEKIND_INT64: {
+      int64_t i64t = 0;
       memcpy(&i64t, nd.data.data(), sizeof(i64t));
       ret_val = std::to_string(i64t);
       break;
-    case UA_DATATYPEKIND_UINT64:
-      uint64_t ui64t;
+    }
+    case UA_DATATYPEKIND_UINT64: {
+      uint64_t ui64t = 0;
       memcpy(&ui64t, nd.data.data(), sizeof(ui64t));
       ret_val = std::to_string(ui64t);
       break;
-    case UA_DATATYPEKIND_FLOAT:
+    }
+    case UA_DATATYPEKIND_FLOAT: {
       if (sizeof(float) == 4 && std::numeric_limits<float>::is_iec559) {
-        float f;
+        float f = NAN;

Review Comment:
   I think you are right, `NAN` was suggested by clang-tidy but using `0` is 
more consistent, updated in 760f6ab8125f79b5454684d6519442d725690a5c



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to