Skip to content

Commit

Permalink
Avoid pointer arithmetic in InputFile and OutputFile
Browse files Browse the repository at this point in the history
  • Loading branch information
rikyoz committed Jan 26, 2025
1 parent ac43d4f commit 0c31939
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/internal/filehandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "bitexception.hpp"
#include "internal/stringutil.hpp"
#include "internal/util.hpp"

#ifndef _WIN32
#include <sys/stat.h> // For S_IRUSR and S_IWUSR
Expand Down Expand Up @@ -127,7 +128,7 @@ auto OutputFile::write( const void* data, std::uint32_t size, std::uint32_t& pro
}
processedSize += bytesWritten;
size -= bytesWritten;
data = static_cast< const bit7z::byte_t* >( data ) + bytesWritten; // NOLINT(*-pro-bounds-pointer-arithmetic)
data = std::next( static_cast< const bit7z::byte_t* >( data ), clamp_cast< std::ptrdiff_t >( bytesWritten ) );
} while ( size > 0 );
return S_OK;
}
Expand Down Expand Up @@ -166,7 +167,7 @@ auto InputFile::read( void* data, std::uint32_t size, std::uint32_t& processedSi
}
processedSize += bytesRead;
size -= bytesRead;
data = static_cast< bit7z::byte_t* >( data ) + bytesRead; // NOLINT(*-pro-bounds-pointer-arithmetic)
data = std::next( static_cast< bit7z::byte_t* >( data ), clamp_cast< std::ptrdiff_t >( bytesRead ) );
} while ( size > 0 );
return S_OK;
}
Expand Down

0 comments on commit 0c31939

Please sign in to comment.