szaszm commented on a change in pull request #754: MINIFICPP-1151 fix most 1st 
party compiler warnings
URL: https://github.com/apache/nifi-minifi-cpp/pull/754#discussion_r408202752
 
 

 ##########
 File path: libminifi/include/core/logging/Logger.h
 ##########
 @@ -47,26 +47,26 @@ class LoggerControl {
   std::atomic<bool> is_enabled_;
 };
 
+inline char const* conditional_conversion(std::string const& str) {
+  return str.c_str();
+}
+
+template<typename T>
+inline T conditional_conversion(T const& t) {
+  return t;
+}
+
 template<typename ... Args>
 inline std::string format_string(char const* format_str, Args&&... args) {
   char buf[LOG_BUFFER_SIZE];
-  std::snprintf(buf, LOG_BUFFER_SIZE, format_str, args...);
+  std::snprintf(buf, LOG_BUFFER_SIZE, format_str, 
conditional_conversion(std::forward<Args>(args))...);
 
 Review comment:
   Workaround:
   Now we call `conditional_conversion` twice on the arguments: once on the 
caller side and once inside `format_string`. This is needed for the 
`PropertyValue` -> `std::string` -> `const char*` path and should have no 
effect elsewhere.
   A proper solution require deeper understanding of the problem.

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


With regards,
Apache Git Services

Reply via email to