Skip to content

Commit

Permalink
xz: Fix a too relaxed assertion and remove uses of SSIZE_MAX.
Browse files Browse the repository at this point in the history
SSIZE_MAX isn't readily available on MSVC. Removing it means
that there is one thing less to worry when porting to MSVC.
  • Loading branch information
Larhzu committed Aug 31, 2023
1 parent 74c3449 commit f7093cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/xz/file_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1157,8 +1157,7 @@ io_fix_src_pos(file_pair *pair, size_t rewind_size)
extern size_t
io_read(file_pair *pair, io_buf *buf, size_t size)
{
// We use small buffers here.
assert(size < SSIZE_MAX);
assert(size <= IO_BUFFER_SIZE);

size_t pos = 0;

Expand Down Expand Up @@ -1285,7 +1284,7 @@ is_sparse(const io_buf *buf)
static bool
io_write_buf(file_pair *pair, const uint8_t *buf, size_t size)
{
assert(size < SSIZE_MAX);
assert(size <= IO_BUFFER_SIZE);

while (size > 0) {
const ssize_t amount = write(pair->dest_fd, buf, size);
Expand Down
4 changes: 2 additions & 2 deletions src/xz/file_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ extern void io_close(file_pair *pair, bool success);
///
/// \param pair File pair having the source file open for reading
/// \param buf Destination buffer to hold the read data
/// \param size Size of the buffer; assumed be smaller than SSIZE_MAX
/// \param size Size of the buffer; must be at most IO_BUFFER_SIZE
///
/// \return On success, number of bytes read is returned. On end of
/// file zero is returned and pair->src_eof set to true.
Expand Down Expand Up @@ -172,7 +172,7 @@ extern bool io_pread(file_pair *pair, io_buf *buf, size_t size, uint64_t pos);
///
/// \param pair File pair having the destination file open for writing
/// \param buf Buffer containing the data to be written
/// \param size Size of the buffer; assumed be smaller than SSIZE_MAX
/// \param size Size of the buffer; must be at most IO_BUFFER_SIZE
///
/// \return On success, zero is returned. On error, -1 is returned
/// and error message printed.
Expand Down

0 comments on commit f7093cd

Please sign in to comment.