You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/03/24 12:10:36 UTC

[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #1036: MINIFICPP-1352 Fix warnings in JNI and Sensors extensions

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



##########
File path: extensions/jni/jvm/JniReferenceObjects.h
##########
@@ -142,7 +142,7 @@ class JniByteInputStream : public minifi::InputStreamCallback {
     int read = 0;
     do {
 
-      int actual = (int) stream_->read(buffer_, remaining <= buffer_size_ ? remaining : buffer_size_);
+      int actual = (int) stream_->read(buffer_, gsl::narrow<uint64_t>(remaining) <= buffer_size_ ? remaining : buffer_size_);

Review comment:
       In any of these cases, we need to add a precondition (`gsl_Expects`) that `size` must not be negative, for the narrowing to be safe. I know that the behavior is identical, but crashing because of narrowing error looks accidental, while a precondition clearly communicates the intent.
   
   




-- 
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:
users@infra.apache.org