mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-08-19 15:56:02 +00:00
Adjust better to Gnulib signed-int read changes
The 2024-08-09 Gnulib changes that caused some modules prefer signed types to size_t means that Tar should follow suit. * src/buffer.c (short_read): * src/system.c (sys_child_open_for_compress) (sys_child_open_for_uncompress): rmtread and safe_read return ptrdiff_t not idx_t; don’t rely on implementation defined conversion. * src/misc.c (blocking_read): Never return a negative number. Return idx_t, not ptrdiff_t, with the same convention for EOF and error as the new full_read. All callers changed. * src/sparse.c (sparse_dump_region, check_sparse_region) (check_data_region): * src/update.c (append_file): full_read no longer returns SAFE_READ_ERROR for I/O error; instead it returns the number of bytes successfully read, and sets errno. Adjust to this. * src/system.c (sys_child_open_for_uncompress): Rewrite to avoid need for goto and label.
This commit is contained in:
+5
-14
@@ -1050,25 +1050,16 @@ dump_regular_file (int fd, struct tar_stat_info *st)
|
||||
memset (blk->buffer + size_left, 0, BLOCKSIZE - beyond);
|
||||
}
|
||||
|
||||
ptrdiff_t count;
|
||||
if (fd <= 0)
|
||||
count = bufsize;
|
||||
else
|
||||
{
|
||||
count = blocking_read (fd, blk->buffer, bufsize);
|
||||
if (count < 0)
|
||||
{
|
||||
read_diag_details (st->orig_file_name,
|
||||
st->stat.st_size - size_left, bufsize);
|
||||
pad_archive (size_left);
|
||||
return dump_status_short;
|
||||
}
|
||||
}
|
||||
idx_t count = (fd <= 0 ? bufsize
|
||||
: blocking_read (fd, blk->buffer, bufsize));
|
||||
size_left -= count;
|
||||
set_next_block_after (blk + (bufsize - 1) / BLOCKSIZE);
|
||||
|
||||
if (count != bufsize)
|
||||
{
|
||||
if (errno)
|
||||
read_diag_details (st->orig_file_name,
|
||||
st->stat.st_size - size_left, bufsize);
|
||||
memset (blk->buffer + count, 0, bufsize - count);
|
||||
warnopt (WARN_FILE_SHRANK, 0,
|
||||
ngettext (("%s: File shrank by %jd byte;"
|
||||
|
||||
Reference in New Issue
Block a user