fgerlits commented on code in PR #1671:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1671#discussion_r1367165495


##########
libminifi/src/core/ProcessSession.cpp:
##########
@@ -175,7 +175,7 @@ std::shared_ptr<core::FlowFile> 
ProcessSession::cloneDuringTransfer(const std::s
 }
 
 std::shared_ptr<core::FlowFile> ProcessSession::clone(const 
std::shared_ptr<core::FlowFile> &parent, int64_t offset, int64_t size) {
-  if ((uint64_t) (offset + size) > parent->getSize()) {
+  if (static_cast<uint64_t>(offset + size) > parent->getSize()) {

Review Comment:
   I would use `gsl::narrow` here, too



##########
extensions/sftp/tests/PutSFTPTests.cpp:
##########
@@ -201,7 +201,7 @@ class PutSFTPTestsFixture {
 
 namespace {
 std::size_t directoryContentCount(const std::filesystem::path& dir) {
-  return (std::size_t)std::distance(std::filesystem::directory_iterator{dir}, 
std::filesystem::directory_iterator{});
+  return 
static_cast<std::size_t>(std::distance(std::filesystem::directory_iterator{dir},
 std::filesystem::directory_iterator{}));

Review Comment:
   `gsl::narrow` may be more appropriate here: if the distance is negative for 
some strange reason, it's better to crash than to return a huge number



##########
libminifi/src/core/flow/StructuredConfiguration.cpp:
##########
@@ -266,10 +266,10 @@ void StructuredConfiguration::parseProcessorNode(const 
Node& processors_node, co
       logger_->log_debug("setting scheduling strategy as {}", 
procCfg.schedulingStrategy);
     }
 
-    int32_t maxConcurrentTasks;
+    int32_t maxConcurrentTasks = 0;
     if (core::Property::StringToInt(procCfg.maxConcurrentTasks, 
maxConcurrentTasks)) {
       logger_->log_debug("parseProcessorNode: maxConcurrentTasks => [{}]", 
maxConcurrentTasks);
-      processor->setMaxConcurrentTasks((uint8_t) maxConcurrentTasks);
+      
processor->setMaxConcurrentTasks(static_cast<uint8_t>(maxConcurrentTasks));
     }

Review Comment:
   would
   ```c++
       uint8_t maxConcurrentTasks;
       if (core::Property::StringToInt(procCfg.maxConcurrentTasks, 
maxConcurrentTasks)) {
         logger_->log_debug("parseProcessorNode: maxConcurrentTasks => [{}]", 
maxConcurrentTasks);
         processor->setMaxConcurrentTasks(maxConcurrentTasks);
       }
   ```
   work?  I think that would be better, if it works.



##########
libminifi/src/provenance/Provenance.cpp:
##########
@@ -249,17 +249,17 @@ bool ProvenanceEventRecord::deserialize(io::InputStream 
&input_stream) {
     }
   }
 
-  uint32_t eventType;
+  uint32_t eventType = 0;
   {
     const auto ret = input_stream.read(eventType);
     if (ret != 4) {
       return false;
     }
   }
 
-  this->_eventType = (ProvenanceEventRecord::ProvenanceEventType) eventType;
+  _eventType = 
static_cast<ProvenanceEventRecord::ProvenanceEventType>(eventType);

Review Comment:
   we could check this:
   ```suggestion
     if (auto event_type_opt = 
magic_enum::enum_cast<ProvenanceEventRecord::ProvenanceEventType>(eventType)) {
       _eventType = *event_type_opt;
     } else {
       return false;
     }
   ```



-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to