]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
xz: Fix a too relaxed assertion and remove uses of SSIZE_MAX.
authorLasse Collin <lasse.collin@tukaani.org>
Thu, 31 Aug 2023 15:14:43 +0000 (18:14 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Tue, 7 May 2024 12:32:03 +0000 (15:32 +0300)
SSIZE_MAX isn't readily available on MSVC. Removing it means
that there is one thing less to worry when porting to MSVC.

(cherry picked from commit ef71f83973a20cc28a3221f85681922026ea33f5)

src/xz/file_io.c
src/xz/file_io.h

index 61629ed3bbeccefc03b63af3aae7e812590bfa90..bec65511bb1e83e867807ed110e3364c5b4a895c 100644 (file)
@@ -1127,8 +1127,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;
 
@@ -1235,7 +1234,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);
index c533d641badb0957872298bf45868384e455cf70..9d59293fe9f7089f23ba3fd5ff9adbe0dfc2db1f 100644 (file)
@@ -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.
@@ -159,7 +159,7 @@ extern bool io_pread(file_pair *pair, io_buf *buf, size_t size, off_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.