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:
Paul Eggert
2024-11-01 09:40:36 -07:00
parent e513950080
commit 7c0feaefd0
8 changed files with 87 additions and 134 deletions

View File

@@ -987,8 +987,12 @@ short_read (idx_t status)
|| (left && status && read_full_records))
{
if (status)
while ((status = rmtread (archive, more, left)) == SAFE_READ_ERROR)
archive_read_error ();
{
ptrdiff_t nread;
while ((nread = rmtread (archive, more, left)) < 0)
archive_read_error ();
status = nread;
}
if (status == 0)
break;