szaszm commented on a change in pull request #1225:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1225#discussion_r769629027



##########
File path: 
extensions/openwsman/processors/SourceInitiatedSubscriptionListener.cpp
##########
@@ -248,9 +248,9 @@ bool SourceInitiatedSubscriptionListener::loadState() {
   return true;
 }
 
-std::string 
SourceInitiatedSubscriptionListener::Handler::millisecondsToXsdDuration(int64_t 
milliseconds) {
+std::string 
SourceInitiatedSubscriptionListener::Handler::millisecondsToXsdDuration(std::chrono::milliseconds
 milliseconds) {
   char buf[1024];
-  snprintf(buf, sizeof(buf), "PT%" PRId64 ".%03" PRId64 "S", milliseconds / 
1000, milliseconds % 1000);
+  snprintf(buf, sizeof(buf), "PT%" PRId64 ".%03" PRId64 "S", 
milliseconds.count() / 1000, milliseconds.count() % 1000);

Review comment:
       `static_cast` works, but wrapping the number in a braced init style 
conversion (i.e. `int64_t{milliseconds.count()}`) is better IMO, because if if 
ever becomes wider than `int64_t`, then that will result in a compiler error. 
(Which is better than silently doing narrowing conversion IMO.)




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