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



##########
File path: libminifi/include/io/AtomicEntryStream.h
##########
@@ -131,23 +132,24 @@ size_t AtomicEntryStream<T>::write(const uint8_t *value, 
size_t size) {
 }
 
 template<typename T>
-size_t AtomicEntryStream<T>::read(uint8_t *buf, size_t buflen) {
-  if (buflen == 0) {
+size_t AtomicEntryStream<T>::read(gsl::span<std::byte> buf) {
+  if (buf.empty()) {
     return 0;
   }
-  if (nullptr != buf && !invalid_stream_) {
+  if (!invalid_stream_) {
     std::lock_guard<std::recursive_mutex> lock(entry_lock_);
-    auto len = buflen;
+    auto len = buf.size();
     core::repository::RepoValue<T> *value;
     if (entry_->getValue(key_, &value)) {
-      if (offset_ + len > value->getBufferSize()) {
-        len = gsl::narrow<int>(value->getBufferSize()) - 
gsl::narrow<int>(offset_);
+      if (offset_ + len > value->getBuffer().size()) {
+        len = value->getBuffer().size() - offset_;
         if (len <= 0) {
           entry_->decrementOwnership();
           return 0;
         }

Review comment:
       I don't know. This piece of code is way too complex and I find it 
difficult to reason about its effects, edge cases, etc. I prefer not to touch 
it any more than the bare minimum required. (this is the 4. nested if block)
   I spent a fair amount of time debugging an issue with the change a few lines 
below this one.




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