Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: haiqi96 <[email protected]>
  • Loading branch information
gibber9809 and haiqi96 authored Dec 6, 2024
1 parent 34ad765 commit 47b0cc0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions components/core/src/clp/CheckpointReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace clp {
auto CheckpointReader::try_seek_from_begin(size_t pos) -> ErrorCode {
m_cur_pos = pos > m_checkpoint ? m_checkpoint : pos;
auto rc = m_reader->try_seek_from_begin(m_cur_pos);
if (ErrorCode_Success != rc) {
if (auto const rc = m_reader->try_seek_from_begin(m_cur_pos);
ErrorCode_Success != rc) {
return rc;
}
if (m_cur_pos >= m_checkpoint) {
Expand All @@ -15,15 +15,15 @@ auto CheckpointReader::try_seek_from_begin(size_t pos) -> ErrorCode {

auto CheckpointReader::try_read(char* buf, size_t num_bytes_to_read, size_t& num_bytes_read)
-> ErrorCode {
if ((m_cur_pos + num_bytes_to_read) > m_checkpoint) {
num_bytes_to_read = m_checkpoint - m_cur_pos;
}

if (m_cur_pos == m_checkpoint) {
return ErrorCode_EndOfFile;
}

if ((m_cur_pos + num_bytes_to_read) > m_checkpoint) {
num_bytes_to_read = m_checkpoint - m_cur_pos;
}

auto rc = m_reader->try_read(buf, num_bytes_to_read, num_bytes_read);
auto const rc = m_reader->try_read(buf, num_bytes_to_read, num_bytes_read);
m_cur_pos += num_bytes_read;
if (ErrorCode_EndOfFile == rc) {
if (0 == num_bytes_read) {
Expand Down

0 comments on commit 47b0cc0

Please sign in to comment.