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


##########
extensions/python/PythonBindings.cpp:
##########
@@ -84,7 +84,7 @@ PyInit_minifi_native(void) {
     Py_INCREF(type.first);
   }
   const auto result = std::all_of(std::begin(types), std::end(types), 
[&](std::pair<PyTypeObject*, std::string_view> type) {
-    return PyModule_AddObject(minifi_module_instance, type.second.data(), 
reinterpret_cast<PyObject*>(type.first)) == 0;
+    return PyModule_AddObject(minifi_module_instance, type.second.data(), 
reinterpret_cast<PyObject*>(type.first)) == 0;  // 
NOLINT(bugprone-suspicious-stringview-data-usage)

Review Comment:
   Replaced the std::string_view with std::string to make sure it is 
null-terminated in 
https://github.com/apache/nifi-minifi-cpp/pull/2040/commits/f66ce5c95061c24f82febd382375e4cec86c41fb



##########
libminifi/src/c2/HeartbeatJsonSerializer.cpp:
##########
@@ -28,7 +28,7 @@ namespace org::apache::nifi::minifi::c2 {
 static void serializeOperationInfo(rapidjson::Value& target, const C2Payload& 
payload, rapidjson::Document::AllocatorType& alloc) {
   gsl_Expects(target.IsObject());
 
-  target.AddMember("operation", 
rapidjson::Value(magic_enum::enum_name<Operation>(payload.getOperation()).data(),
 alloc), alloc);
+  target.AddMember("operation", 
rapidjson::Value(magic_enum::enum_name<Operation>(payload.getOperation()).data(),
 alloc), alloc);  // NOLINT(bugprone-suspicious-stringview-data-usage)

Review Comment:
   Added comment that magic_enum ensures null-terminated strings in this case 
in 
https://github.com/apache/nifi-minifi-cpp/pull/2040/commits/f66ce5c95061c24f82febd382375e4cec86c41fb
 Unfortunately I could not ensure it with a valid static_assert



##########
libminifi/test/unit/SiteToSiteTests.cpp:
##########
@@ -236,9 +236,8 @@ TEST_CASE("TestSiteToSiteVerifySend using flowfile data", 
"[S2S]") {
 TEST_CASE("TestSiteToSiteVerifyNegotiationFail", "[S2S]") {
   auto collector = std::make_unique<SiteToSiteResponder>();
 
-  const char negotiated_abort_code = 
magic_enum::enum_underlying(sitetosite::ResourceNegotiationStatusCode::NEGOTIATED_ABORT);
-  std::string resp_code;
-  resp_code.insert(resp_code.begin(), negotiated_abort_code);
+  const auto negotiated_abort_code = 
magic_enum::enum_underlying(sitetosite::ResourceNegotiationStatusCode::NEGOTIATED_ABORT);
+  const std::string resp_code{reinterpret_cast<const 
char*>(&negotiated_abort_code), 1};

Review Comment:
   Updated in 
https://github.com/apache/nifi-minifi-cpp/pull/2040/commits/f66ce5c95061c24f82febd382375e4cec86c41fb



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