Prefer signed types in blocking_read etc

* src/compare.c (process_noop, process_rawdata):
Return bool, not int.
* src/compare.c (process_noop, process_rawdata):
* src/create.c (dump_regular_file):
* src/extract.c (extract_file):
* src/misc.c (blocking_read, blocking_write):
* src/sparse.c (sparse_scan_file_raw, sparse_extract_region):
Prefer signed types like idx_t to unsigned ones like size_t.
(sparse_scan_file_raw): Diagnose read errors.
This commit is contained in:
Paul Eggert
2024-08-14 23:25:46 -07:00
parent 88c2aa1616
commit b3992e4ef8
6 changed files with 62 additions and 57 deletions
+16 -12
View File
@@ -1047,28 +1047,32 @@ dump_regular_file (int fd, struct tar_stat_info *st)
mv_begin_write (st->file_name, st->stat.st_size, st->stat.st_size);
while (size_left > 0)
{
size_t bufsize, count;
blk = find_next_block ();
bufsize = available_space_after (blk);
idx_t bufsize = available_space_after (blk);
if (size_left < bufsize)
{
/* Last read -- zero out area beyond. */
bufsize = size_left;
count = bufsize % BLOCKSIZE;
if (count)
memset (blk->buffer + size_left, 0, BLOCKSIZE - count);
idx_t beyond = bufsize % BLOCKSIZE;
if (beyond)
memset (blk->buffer + size_left, 0, BLOCKSIZE - beyond);
}
count = (fd <= 0) ? bufsize : blocking_read (fd, blk->buffer, bufsize);
if (count == SAFE_READ_ERROR)
ptrdiff_t count;
if (fd <= 0)
count = bufsize;
else
{
read_diag_details (st->orig_file_name,
st->stat.st_size - size_left, bufsize);
pad_archive (size_left);
return dump_status_short;
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;
}
}
size_left -= count;
set_next_block_after (blk + (bufsize - 1) / BLOCKSIZE);