ronantakizawa/codereview-bench huggingface dataset:
Repository: oatpp/oatpp
File: src/oatpp/core/data/mapping/type/Primitive.hpp (C++)

Code before:
      )
  {}

  String(const std::shared_ptr<std::string>& ptr)
    : type::ObjectWrapper<std::string, __class::String>(ptr)
  {}

  String(std::shared_ptr<std::string>&& ptr)
    : type::ObjectWrapper<std::string, __class::String>(std::forward<std::shared_ptr<std::string>>(ptr))
  {}

  String(const String& other)
    : type::ObjectWrapper<std::string, __class::String>(other)
  {}

  String(String&& other)
    : type::ObjectWrapper<std::string, __class::String>(std::forward<String>(other))
  {}

  const std::string& operator*() const {
    return this->m_ptr.operator*();
  }

  operator std::string() const
  {
      return this->m_ptr.operator*();
  }

  template<typename T,
    typename enabled = typename std::enable_if<std::is_same<T, std::nullptr_t>::value, void>::type
  >
  inline String& operator = (std::nullptr_t) {
    m_ptr.reset();
    return *this;
  }

  template<typename T,
    typename enabled = typename std::enable_if<std::is_same<T, char>::value, void>::type
  >
  inline String& operator = (const T* str) {
    m_ptr = std::make_shared<std::string>(str);
    return *this;
  }

  template<typename T,
    typename enabled = typename std::enable_if<std::is_same<T, std::string>::value, void>::type
  >
  inline String& operator = (const T& str) {
    m_ptr = std::make_shared<std::string>(str);
    return *this;
  }

Review comment (bug):
Since it's an implicit conversion with implicit dereferencing
I suggest adding `throw` in case of `m_ptr == nullptr`

Code after:
        std::make_shared<std::string>(std::forward<std::string>(str))
      )
  {}

  String(const std::shared_ptr<std::string>& ptr)
    : type::ObjectWrapper<std::string, __class::String>(ptr)
  {}

  String(std::shared_ptr<std::string>&& ptr)
    : type::ObjectWrapper<std::string, __class::String>(std::forward<std::shared_ptr<std::string>>(ptr))
  {}

  String(const String& other)
    : type::ObjectWrapper<std::string, __class::String>(other)
  {}

  String(String&& other)
    : type::ObjectWrapper<std::string, __class::String>(std::forward<String>(other))
  {}

  const std::string& operator*() const {
    if (this->m_ptr == nullptr) throw std::runtime_error("[oatpp::data::mapping::type::String] Error: m_ptr points to null.");
    return this->m_ptr.operator*();
  }

  operator std::string() const
  {
    if (this->m_ptr == nullptr) throw std::runtime_error("[oatpp::data::mapping::type::String] Error: m_ptr points to null.");
    return this->m_ptr.operator*();
  }

  template<typename T,
    typename enabled = typename std::enable_if<std::is_same<T, std::nullptr_t>::value, void>::type
  >
  inline String& operator = (std::nullptr_t) {
    m_ptr.reset();
    return *this;
  }

  template<typename T,
    typename enabled = typename std::enable_if<std::is_same<T, char>::value, void>::type
  >
  inline String& operator = (const T* str) {
    m_ptr = std::make_shared<std::string>(str);
    return *this;
  }

  template<typename T,
    typename enabled = typename std::enable_if<std::is_same<T, std::string>::value, void>::type
  >
  inline String& operator = (const T& str) {
Repository: oatpp/oatpp
File: src/oatpp/network/Server.cpp (C++)

Code before:

bool Server::setStatus(v_int32 expectedStatus, v_int32 newStatus) {
  v_int32 expected = expectedStatus;
  return m_status.compare_exchange_weak(expected, newStatus);
}

void Server::setStatus(v_int32 status) {
  m_status.store(status);
}

v_int32 Server::getStatus() {
  return m_status.load();
}

void Server::setConnectionProvider(const std::shared_ptr<ServerConnectionProvider> &connectionProvider) {
  m_connectionProvider = connectionProvider;
}

void Server::setConnectionHandler(const std::shared_ptr<ConnectionHandler> &connectionHandler) {
  m_connectionHandler = connectionHandler;
}

Server::~Server() {
  stop();
}

}}


Review comment (suggestion):
I think we should protect with the spin-lock.
Since server run loop is running in a different thread.

Code after:
    case STATUS_RUNNING:
      setStatus(STATUS_STOPPING);
      break;
  }

  if (m_threaded && m_thread.joinable()) {
    m_thread.join();
  }
}

bool Server::setStatus(v_int32 expectedStatus, v_int32 newStatus) {
  v_int32 expected = expectedStatus;
  return m_status.compare_exchange_weak(expected, newStatus);
}

void Server::setStatus(v_int32 status) {
  m_status.store(status);
}

v_int32 Server::getStatus() {
  return m_status.load();
}

void Server::setConnectionProvider(const std::shared_ptr<ServerConnectionProvider> &connectionProvider) {
  std::lock_guard<oatpp::concurrency::SpinLock> lg(m_spinlock);
  m_connectionProvider = connectionProvider;
}

void Server::setConnectionHandler(const std::shared_ptr<ConnectionHandler> &connectionHandler) {
  std::lock_guard<oatpp::concurrency::SpinLock> lg(m_spinlock);
  m_connectionHandler = connectionHandler;
}

Server::~Server() {
  stop();
}

}}
Repository: oatpp/oatpp
File: src/oatpp-test/UnitTest.hpp (C++)

Code before:
   * Optionally override this method. It should contain logic run after all test iterations.
   */
  void after(){};

  /**
   * Run this test repeatedly for specified number of times.
   * @tparam T - Test class.
   * @param times - number of times to run this test.
   */
  template<class T>
  static void runTest(v_int32 times){
    T test;
    test.run(times);
  }
  
};

/**
 * Convenience macro to run test. <br>
 * Usage Example:<br>
 * `OATPP_RUN_TEST(oatpp::test::web::FullTest);`
 */
#define OATPP_RUN_TEST(TEST) \
oatpp::test::UnitTest::runTest<TEST>(1)
/**
 * Convenience macro to run test multiple times in a row. <br>
 * Usage Example:<br>
 * `OATPP_RUN_TEST(oatpp::test::web::FullTest, 5);`
 */
#define OATPP_RUN_TEST_N(TEST, N) \
oatpp::test::UnitTest::runTest<TEST>(N)
  
}}

#endif /* oatpp_test_UnitTest_hpp */


Review comment (suggestion):
This whole thing should be replaced with the macro-selector logic from src/oatpp/core/macro/basic.hpp

```c++
#define OATPP_MACRO_TEST_MACRO_SELECTOR(MACRO, TYPE, ...) \
OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_SELECTOR(MACRO, (__VA_ARGS__)) (TYPE, __VA_ARGS__))

#define OATPP_RUN_TEST_0(TEST) \
oatpp::test::UnitTest::runTest<TEST>(1)

#define OATPP_RUN_TEST_1(TEST, N) \
oatpp::test::UnitTest::runTest<TEST>(N)

#define OATPP_RUN_TEST(TYPE, PARAM_LIST) \
OATPP_MACRO_TEST_MACRO_SELECTOR(OATPP_RUN_TEST_, TYPE, OATPP_MACRO_UNFOLD_VA_ARGS PARAM_LIST)
```

Code after:
   * Optionally override this method. It should contain logic run after all test iterations.
   */
  virtual void after(){};

  /**
   * Run this test repeatedly for specified number of times.
   * @tparam T - Test class.
   * @param times - number of times to run this test.
   */
  template<class T>
  static void runTest(v_int32 times){
    T test;
    test.run(times);
  }
  
};

#define OATPP_RUN_TEST_0(TEST) \
oatpp::test::UnitTest::runTest<TEST>(1)
#define OATPP_RUN_TEST_1(TEST, N) \
oatpp::test::UnitTest::runTest<TEST>(N)
/**
 * Convenience macro to run test. <br>
 * Usage Example:<br>
 * `OATPP_RUN_TEST(oatpp::test::web::FullTest);`
 * Running the test 10 times:
 * `OATPP_RUN_TEST(oatpp::test::web::FullTest, 10);`
 */
#define OATPP_RUN_TEST(...) \
OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_RUN_TEST_, (__VA_ARGS__)) (__VA_ARGS__))

}}

#endif /* oatpp_test_UnitTest_hpp */
Repository: oatpp/oatpp
File: src/oatpp-test/UnitTest.hpp (C++)

Code before:

  /**
   * Run this test repeatedly for specified number of times.
   * @tparam T - Test class.
   * @param times - number of times to run this test.
   */
  template<class T>
  static void runTest(v_int32 times){
    T test;
    test.run(times);
  }
  
};

/**
 * Convenience macro to run test. <br>
 * Usage Example:<br>
 * `OATPP_RUN_TEST(oatpp::test::web::FullTest);`
 */
#define OATPP_RUN_TEST_0(TEST) \
oatpp::test::UnitTest::runTest<TEST>(1)
#define OATPP_RUN_TEST_1(TEST, N) \
oatpp::test::UnitTest::runTest<TEST>(N)
#define OATPP_RUN_TEST(...) \
OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_RUN_TEST_, (__VA_ARGS__)) (__VA_ARGS__))

}}

#endif /* oatpp_test_UnitTest_hpp */


Review comment (suggestion):
```suggestion
/**
 * Convenience macro to run test. <br>
 * Usage Example:<br>
 * `OATPP_RUN_TEST(oatpp::test::web::FullTest);`
 * Running the test 10 times:
 * `OATPP_RUN_TEST(oatpp::test::web::FullTest, 10);`
 */
#define OATPP_RUN_TEST(...) \
```

Code after:

  /**
   * Run this test repeatedly for specified number of times.
   * @tparam T - Test class.
   * @param times - number of times to run this test.
   */
  template<class T>
  static void runTest(v_int32 times){
    T test;
    test.run(times);
  }
  
};

#define OATPP_RUN_TEST_0(TEST) \
oatpp::test::UnitTest::runTest<TEST>(1)
#define OATPP_RUN_TEST_1(TEST, N) \
oatpp::test::UnitTest::runTest<TEST>(N)
/**
 * Convenience macro to run test. <br>
 * Usage Example:<br>
 * `OATPP_RUN_TEST(oatpp::test::web::FullTest);`
 * Running the test 10 times:
 * `OATPP_RUN_TEST(oatpp::test::web::FullTest, 10);`
 */
#define OATPP_RUN_TEST(...) \
OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_RUN_TEST_, (__VA_ARGS__)) (__VA_ARGS__))

}}

#endif /* oatpp_test_UnitTest_hpp */
Repository: oatpp/oatpp
File: src/oatpp/parser/json/Utils.cpp (C++)

Code before:
  v_buff_size size;
  auto data = preparseString(caret, size);
  
  if(data != nullptr) {
    
    v_buff_size pos = caret.getPosition();
    
    v_int64 errorCode;
    v_buff_size errorPosition;
    const std::string& result = unescapeStringToStdString(data, size, errorCode, errorPosition);
    if(errorCode != 0){
      caret.setError("[oatpp::parser::json::Utils::parseStringToStdString()]: Error. Call to unescapeStringToStdString() failed", errorCode);
      caret.setPosition(pos + errorPosition);
    } else {
      caret.setPosition(pos + size + 1);
    }
    
    return result;
    
  }
  
  return "";
  
}

bool Utils::findDecimalSeparatorInNextWord(const char* data) {
  while (*data != '\0' && std::isspace(*data) == 0) {
    if (*data == JSON_DECIMAL_SEPARATOR) {
      return true;
    }
    ++data;
  }
  return false;
}
  
}}}


Review comment (suggestion):
This method take `ParsingCaret& caret` as a parameter because we are bounded by caret.dataSize and not by '\0' char.

Code after:
  v_buff_size size;
  auto data = preparseString(caret, size);
  
  if(data != nullptr) {
    
    v_buff_size pos = caret.getPosition();
    
    v_int64 errorCode;
    v_buff_size errorPosition;
    const std::string& result = unescapeStringToStdString(data, size, errorCode, errorPosition);
    if(errorCode != 0){
      caret.setError("[oatpp::parser::json::Utils::parseStringToStdString()]: Error. Call to unescapeStringToStdString() failed", errorCode);
      caret.setPosition(pos + errorPosition);
    } else {
      caret.setPosition(pos + size + 1);
    }
    
    return result;
    
  }
  
  return "";
  
}

bool Utils::findDecimalSeparatorInCurrentNumber(ParsingCaret& caret) {
  parser::Caret::StateSaveGuard stateGuard(caret);

  // search until a decimal separator is found or no more digits are found or no more data available
  while(caret.canContinue()) {
    if (caret.isAtChar(JSON_DECIMAL_SEPARATOR)) {
      return true;
    }
    if (!caret.isAtDigitChar()) {
      return false;
    }
    caret.inc();
  }
  return false;
}
  
}}}
Repository: oatpp/oatpp
File: src/oatpp/parser/json/Utils.cpp (C++)

Code before:
  auto data = preparseString(caret, size);
  
  if(data != nullptr) {
    
    v_buff_size pos = caret.getPosition();
    
    v_int64 errorCode;
    v_buff_size errorPosition;
    const std::string& result = unescapeStringToStdString(data, size, errorCode, errorPosition);
    if(errorCode != 0){
      caret.setError("[oatpp::parser::json::Utils::parseStringToStdString()]: Error. Call to unescapeStringToStdString() failed", errorCode);
      caret.setPosition(pos + errorPosition);
    } else {
      caret.setPosition(pos + size + 1);
    }
    
    return result;
    
  }
  
  return "";
  
}

bool Utils::findDecimalSeparatorInNextWord(const char* data) {
  while (*data != '\0' && std::isspace(*data) == 0) {
    if (*data == JSON_DECIMAL_SEPARATOR) {
      return true;
    }
    ++data;
  }
  return false;
}
  
}}}


Review comment (bug):
This condition should be changed. 
It checks for `\0` char or until `std::isspace == false` which is incorrect.
Consider the following JSON:

```json
{"a":1,"b":1.1}
```

in this case this method will be evaluated to true when checking `a` since it won't stop on the `,`.

Code after:
  auto data = preparseString(caret, size);
  
  if(data != nullptr) {
    
    v_buff_size pos = caret.getPosition();
    
    v_int64 errorCode;
    v_buff_size errorPosition;
    const std::string& result = unescapeStringToStdString(data, size, errorCode, errorPosition);
    if(errorCode != 0){
      caret.setError("[oatpp::parser::json::Utils::parseStringToStdString()]: Error. Call to unescapeStringToStdString() failed", errorCode);
      caret.setPosition(pos + errorPosition);
    } else {
      caret.setPosition(pos + size + 1);
    }
    
    return result;
    
  }
  
  return "";
  
}

bool Utils::findDecimalSeparatorInCurrentNumber(ParsingCaret& caret) {
  parser::Caret::StateSaveGuard stateGuard(caret);

  // search until a decimal separator is found or no more digits are found or no more data available
  while(caret.canContinue()) {
    if (caret.isAtChar(JSON_DECIMAL_SEPARATOR)) {
      return true;
    }
    if (!caret.isAtDigitChar()) {
      return false;
    }
    caret.inc();
  }
  return false;
}
  
}}}
Repository: oatpp/oatpp
File: src/oatpp/web/mime/multipart/PartList.hpp (C++)

Code before:
  /**
   * Read part-by-part from Multipart.
   * @return
   */
  std::shared_ptr<Part> readNextPart(async::Action& action) override;

  /**
   * Write part-by-part to Multipart.
   * @param part
   */
  void writeNextPart(const std::shared_ptr<Part>& part, async::Action& action) override;

  /**
   * Get part by name <br>
   * Returns the first part if multiple parts with same name exist.
   * Applicable to named parts only.
   * @param name - &id:oatpp::String;.
   * @return - &id:oatpp::web::mime::multipart::Part;.
   */
  std::shared_ptr<Part> getNamedPart(const oatpp::String& name);

  /**
   * Get all parts by name <br>
   * Applicable to named parts only.
   * @param name - &id:oatpp::String;.
   * @return - std::list<std::shared_ptr<&id:oatpp::web::mime::multipart::Part;>>.
   */
  std::list<std::shared_ptr<Part>> getNamedParts(const oatpp::String& name);

  /**
   * Get list of all parts.
   * @return - `std::list` of `std::shared_ptr` to &id:oatpp::web::mime::multipart::Part;.
   */
  const std::list<std::shared_ptr<Part>>& getAllParts();

  /**
   * Get parts count.
   * @return - parts count.
   */
  v_int64 count();

};

}}}}

#endif //oatpp_web_mime_multipart_PartList_hpp


Review comment (security):
please escape triangle brackets:

```
@return - std::list<std::shared_ptr<&id:oatpp::web::mime::multipart::Part;>>.
```

change to

```
@return - std::list&lt;std::shared_ptr&lt;&id:oatpp::web::mime::multipart::Part;&gt;&gt;.
```

Code after:
  /**
   * Read part-by-part from Multipart.
   * @return
   */
  std::shared_ptr<Part> readNextPart(async::Action& action) override;

  /**
   * Write part-by-part to Multipart.
   * @param part
   */
  void writeNextPart(const std::shared_ptr<Part>& part, async::Action& action) override;

  /**
   * Get part by name <br>
   * Returns the first part if multiple parts with same name exist.
   * Applicable to named parts only.
   * @param name - &id:oatpp::String;.
   * @return - `std::shared_ptr` to &id:oatpp::web::mime::multipart::Part;.
   */
  std::shared_ptr<Part> getNamedPart(const oatpp::String& name);

  /**
   * Get all parts by name <br>
   * Applicable to named parts only.
   * @param name - &id:oatpp::String;.
   * @return - `std::list` of `std::shared_ptr` to &id:oatpp::web::mime::multipart::Part;.
   */
  std::list<std::shared_ptr<Part>> getNamedParts(const oatpp::String& name);

  /**
   * Get list of all parts.
   * @return - `std::list` of `std::shared_ptr` to &id:oatpp::web::mime::multipart::Part;.
   */
  const std::list<std::shared_ptr<Part>>& getAllParts();

  /**
   * Get parts count.
   * @return - parts count.
   */
  v_int64 count();

};

}}}}

#endif //oatpp_web_mime_multipart_PartList_hpp
Repository: oatpp/oatpp
File: src/oatpp/algorithm/CRC.cpp (C++)

Code before:
  
  p_uint32 result = new v_uint32[256];
  v_uint32 polyReverse = bitReverse(poly);
  v_uint32 value;
  
  for(v_int32 i = 0; i < 256; i++) {
    value = i;
    for (v_int32 bit = 0; bit < 8; bit++) {
      if (value & 1) {
        value = (value >> 1) ^ polyReverse;
      } else {
        value = (value >> 1);
      }
    }
    
    result[i] = value;
    
  }
  
  return result;
  
}
  
v_uint32 CRC32::calc(const void *buffer, v_buff_size size, v_uint32 crc, v_uint32 initValue, v_uint32 xorOut, p_uint32 table) {
  
  p_uint8 data = reinterpret_cast<p_uint8>(const_cast<void*>(buffer));
  crc = crc ^ initValue;
  
  for(v_buff_size i = 0; i < size; i++) {
    crc = table[(crc & 0xFF) ^ data[i]] ^ (crc >> 8);
  }
  
  return crc ^ xorOut;
}
  
}}


Review comment (suggestion):
let's use:

```cpp
auto data = reinterpret_cast<const char*>(buffer);
```

Code after:
  
  p_uint32 result = new v_uint32[256];
  v_uint32 polyReverse = bitReverse(poly);
  v_uint32 value;
  
  for(v_int32 i = 0; i < 256; i++) {
    value = i;
    for (v_int32 bit = 0; bit < 8; bit++) {
      if (value & 1) {
        value = (value >> 1) ^ polyReverse;
      } else {
        value = (value >> 1);
      }
    }
    
    result[i] = value;
    
  }
  
  return result;
  
}
  
v_uint32 CRC32::calc(const void *buffer, v_buff_size size, v_uint32 crc, v_uint32 initValue, v_uint32 xorOut, p_uint32 table) {
  
  auto data = reinterpret_cast<const char*>(buffer);
  crc = crc ^ initValue;
  
  for(v_buff_size i = 0; i < size; i++) {
    crc = table[(crc & 0xFF) ^ data[i]] ^ (crc >> 8);
  }
  
  return crc ^ xorOut;
}
  
}}
Repository: oatpp/oatpp
File: src/oatpp/core/data/buffer/FIFOBuffer.cpp (C++)

Code before:
  
  if(m_writePosition < m_readPosition) {
    auto size = m_readPosition - m_writePosition;
    if(size > count) {
      size = count;
    }
    std::memcpy(&m_buffer[m_writePosition], data, static_cast<size_t>(size));
    m_writePosition += size;
    return size;
  }
  
  auto size = m_bufferSize - m_writePosition;
  
  if(size > count){
    std::memcpy(&m_buffer[m_writePosition], data, static_cast<size_t>(count));
    m_writePosition += count;
    return count;
  }
  
  std::memcpy(&m_buffer[m_writePosition], data, static_cast<size_t>(size));
  auto size2 = m_readPosition;
  if(size2 > count - size) {
    size2 = count - size;
  }
  
  std::memcpy(m_buffer, &(reinterpret_cast<p_char8>(const_cast<void*>(data)))[size], static_cast<size_t>(size2));
  m_writePosition = size2;
  
  return (size + size2);
  
}

v_io_size FIFOBuffer::readAndWriteToStream(data::stream::WriteCallback* stream, v_buff_size count, async::Action& action) {

  if(!m_canRead) {
    return IOError::RETRY_READ;
  }

  if(count == 0) {
    return 0;
  } else if(count < 0) {
    throw std::runtime_error("[oatpp::data::buffer::FIFOBuffer::readAndWriteToStream(...)]: count < 0");
  }

  if(m_readPosition < m_writePosition) {
    auto size = m_writePosition - m_readPosition;
    if(size > count) {
      size = count;
    }
    auto bytesWritten = stream->write(&m_buffer[m_readPosition], size, action);
    if(bytesWritten > 0) {

Review comment (suggestion):
Let's use just:

```cpp
&(reinterpret_cast<const char*>(data))[size]
```

Code after:
  
  if(m_writePosition < m_readPosition) {
    auto size = m_readPosition - m_writePosition;
    if(size > count) {
      size = count;
    }
    std::memcpy(&m_buffer[m_writePosition], data, static_cast<size_t>(size));
    m_writePosition += size;
    return size;
  }
  
  auto size = m_bufferSize - m_writePosition;
  
  if(size > count){
    std::memcpy(&m_buffer[m_writePosition], data, static_cast<size_t>(count));
    m_writePosition += count;
    return count;
  }
  
  std::memcpy(&m_buffer[m_writePosition], data, static_cast<size_t>(size));
  auto size2 = m_readPosition;
  if(size2 > count - size) {
    size2 = count - size;
  }
  
  std::memcpy(m_buffer, &(reinterpret_cast<const char*>(data))[size], static_cast<size_t>(size2));
  m_writePosition = size2;
  
  return (size + size2);
  
}

v_io_size FIFOBuffer::readAndWriteToStream(data::stream::WriteCallback* stream, v_buff_size count, async::Action& action) {

  if(!m_canRead) {
    return IOError::RETRY_READ;
  }

  if(count == 0) {
    return 0;
  } else if(count < 0) {
    throw std::runtime_error("[oatpp::data::buffer::FIFOBuffer::readAndWriteToStream(...)]: count < 0");
  }

  if(m_readPosition < m_writePosition) {
    auto size = m_writePosition - m_readPosition;
    if(size > count) {
      size = count;
    }
    auto bytesWritten = stream->write(&m_buffer[m_readPosition], size, action);
    if(bytesWritten > 0) {
Repository: oatpp/oatpp
File: src/oatpp/core/data/buffer/Processor.cpp (C++)

Code before:
v_io_size ProcessingPipeline::suggestInputStreamReadSize() {
  return m_processors[0]->suggestInputStreamReadSize();
}

v_int32 ProcessingPipeline::iterate(data::buffer::InlineReadData& dataIn,
                                    data::buffer::InlineReadData& dataOut)
{

  if(dataOut.bytesLeft > 0) {
    return Error::FLUSH_DATA_OUT;
  }

  v_int32 i = 0;
  v_int32 res = Error::OK;

  while(res == Error::OK) {

    auto& p = m_processors[i];

    data::buffer::InlineReadData* currDataIn = &dataIn;
    if(i > 0) {
      currDataIn = &m_intermediateData[i - 1];
    }

    data::buffer::InlineReadData* currDataOut = &dataOut;
    if(i < static_cast<v_int32>(m_intermediateData.size())) {
      currDataOut = &m_intermediateData[i];
    }

    while(res == Error::OK) {
      res = p->iterate(*currDataIn, *currDataOut);
    }

    const v_int32 numOfProcessors = v_int32(m_processors.size());

    switch (res) {
      case Error::PROVIDE_DATA_IN:
        if (i > 0) {
          i --;
          res = Error::OK;
        }
        break;


      case Error::FLUSH_DATA_OUT:
        if (i < numOfProcessors - 1) {
          i ++;
          res = Error::OK;
        }
        break;


Review comment (suggestion):
Let's change type of `i` to `v_buff_size`. No cast needed 

Code after:
v_io_size ProcessingPipeline::suggestInputStreamReadSize() {
  return m_processors[0]->suggestInputStreamReadSize();
}

v_int32 ProcessingPipeline::iterate(data::buffer::InlineReadData& dataIn,
                                    data::buffer::InlineReadData& dataOut)
{

  if(dataOut.bytesLeft > 0) {
    return Error::FLUSH_DATA_OUT;
  }

  v_buff_size i = 0;
  v_int32 res = Error::OK;

  while(res == Error::OK) {

    auto& p = m_processors[i];

    data::buffer::InlineReadData* currDataIn = &dataIn;
    if(i > 0) {
      currDataIn = &m_intermediateData[i - 1];
    }

    data::buffer::InlineReadData* currDataOut = &dataOut;
    if(i < m_intermediateData.size()) {
      currDataOut = &m_intermediateData[i];
    }

    while(res == Error::OK) {
      res = p->iterate(*currDataIn, *currDataOut);
    }

    const v_int32 numOfProcessors = v_int32(m_processors.size());

    switch (res) {
      case Error::PROVIDE_DATA_IN:
        if (i > 0) {
          i --;
          res = Error::OK;
        }
        break;


      case Error::FLUSH_DATA_OUT:
        if (i < numOfProcessors - 1) {
          i ++;
          res = Error::OK;
        }
        break;