Prefer idx_t to size_t in system.c
* src/buffer.c (_flush_write): Return idx_t, not ssize_t, to accommodate system.c changes. All uses changed. (_gnu_flush_write): Output correct errno value after write error. Simplify multi-volume mode. * src/system.c (sys_write_archive_buffer) (sys_child_open_for_compress, sys_exec_setmtime_script): Prefer idx_t to size_t.
This commit is contained in:
29
src/buffer.c
29
src/buffer.c
@@ -872,10 +872,10 @@ _open_archive (enum access_mode wanted_access)
|
||||
}
|
||||
|
||||
/* Perform a write to flush the buffer. */
|
||||
static ssize_t
|
||||
static idx_t
|
||||
_flush_write (void)
|
||||
{
|
||||
ssize_t status;
|
||||
idx_t status;
|
||||
|
||||
checkpoint_run (true);
|
||||
if (tape_length_option && tape_length_option <= bytes_written)
|
||||
@@ -1826,9 +1826,7 @@ simple_flush_read (void)
|
||||
static void
|
||||
simple_flush_write (MAYBE_UNUSED idx_t level)
|
||||
{
|
||||
ssize_t status;
|
||||
|
||||
status = _flush_write ();
|
||||
idx_t status = _flush_write ();
|
||||
if (status != record_size)
|
||||
archive_write_error (status);
|
||||
else
|
||||
@@ -1895,22 +1893,15 @@ gnu_flush_read (void)
|
||||
static void
|
||||
_gnu_flush_write (idx_t buffer_level)
|
||||
{
|
||||
ssize_t status;
|
||||
union block *header;
|
||||
char *copy_ptr;
|
||||
idx_t copy_size;
|
||||
idx_t bufsize;
|
||||
struct bufmap *map;
|
||||
|
||||
status = _flush_write ();
|
||||
if (status != record_size && !multi_volume_option)
|
||||
archive_write_error (status);
|
||||
else
|
||||
{
|
||||
if (status)
|
||||
records_written++;
|
||||
bytes_written += status;
|
||||
}
|
||||
idx_t status = _flush_write ();
|
||||
records_written += !!status;
|
||||
bytes_written += status;
|
||||
|
||||
if (status == record_size)
|
||||
{
|
||||
@@ -1921,15 +1912,19 @@ _gnu_flush_write (idx_t buffer_level)
|
||||
|
||||
if (status % BLOCKSIZE)
|
||||
{
|
||||
int e = errno;
|
||||
paxerror (0, _("write did not end on a block boundary"));
|
||||
errno = e;
|
||||
archive_write_error (status);
|
||||
}
|
||||
|
||||
/* In multi-volume mode. */
|
||||
/* ENXIO is for the UNIX PC. */
|
||||
if (status < 0 && errno != ENOSPC && errno != EIO && errno != ENXIO)
|
||||
if (! (multi_volume_option
|
||||
&& (errno == ENOSPC || errno == EIO || errno == ENXIO)))
|
||||
archive_write_error (status);
|
||||
|
||||
/* In multi-volume mode. */
|
||||
|
||||
if (!new_volume (ACCESS_WRITE))
|
||||
return;
|
||||
|
||||
|
||||
@@ -928,7 +928,7 @@ bool sys_compare_links (struct stat *link_data, struct stat *stat_data);
|
||||
int sys_truncate (int fd);
|
||||
pid_t sys_child_open_for_compress (void);
|
||||
pid_t sys_child_open_for_uncompress (void);
|
||||
size_t sys_write_archive_buffer (void);
|
||||
idx_t sys_write_archive_buffer (void);
|
||||
bool sys_get_archive_stat (void);
|
||||
int sys_exec_command (char *file_name, int typechar, struct tar_stat_info *st);
|
||||
void sys_wait_command (void);
|
||||
|
||||
20
src/system.c
20
src/system.c
@@ -137,7 +137,7 @@ sys_truncate (int fd)
|
||||
return write (fd, "", 0);
|
||||
}
|
||||
|
||||
size_t
|
||||
idx_t
|
||||
sys_write_archive_buffer (void)
|
||||
{
|
||||
return full_write (archive, record_start->buffer, record_size);
|
||||
@@ -306,7 +306,7 @@ is_regular_file (const char *name)
|
||||
return errno == ENOENT;
|
||||
}
|
||||
|
||||
size_t
|
||||
idx_t
|
||||
sys_write_archive_buffer (void)
|
||||
{
|
||||
return rmtwrite (archive, record_start->buffer, record_size);
|
||||
@@ -462,7 +462,7 @@ sys_child_open_for_compress (void)
|
||||
length < record_size;
|
||||
length += status, cursor += status)
|
||||
{
|
||||
size_t size = record_size - length;
|
||||
idx_t size = record_size - length;
|
||||
|
||||
status = safe_read (STDIN_FILENO, cursor, size);
|
||||
if (status < 0)
|
||||
@@ -935,8 +935,8 @@ sys_exec_setmtime_script (const char *script_name,
|
||||
struct pollfd pfd;
|
||||
|
||||
char *buffer = NULL;
|
||||
size_t buflen = 0;
|
||||
size_t bufsize = 0;
|
||||
idx_t buflen = 0;
|
||||
idx_t bufsize = 0;
|
||||
char *cp;
|
||||
int rc = 0;
|
||||
|
||||
@@ -968,6 +968,8 @@ sys_exec_setmtime_script (const char *script_name,
|
||||
open_error (dev_null);
|
||||
|
||||
priv_set_restore_linkdir ();
|
||||
/* FIXME: This mishandles shell metacharacters in the file name.
|
||||
Come to think of it, isn't every use of xexec suspect? */
|
||||
xexec (command);
|
||||
}
|
||||
close (p[1]);
|
||||
@@ -992,11 +994,7 @@ sys_exec_setmtime_script (const char *script_name,
|
||||
if (pfd.revents & POLLIN)
|
||||
{
|
||||
if (buflen == bufsize)
|
||||
{
|
||||
if (bufsize == 0)
|
||||
bufsize = BUFSIZ;
|
||||
buffer = x2nrealloc (buffer, &bufsize, 1);
|
||||
}
|
||||
buffer = xpalloc (buffer, &bufsize, 1, -1, 1);
|
||||
ssize_t nread = read (pfd.fd, buffer + buflen, bufsize - buflen);
|
||||
if (nread < 0)
|
||||
{
|
||||
@@ -1036,7 +1034,7 @@ sys_exec_setmtime_script (const char *script_name,
|
||||
else
|
||||
{
|
||||
if (buflen == bufsize)
|
||||
buffer = x2nrealloc (buffer, &bufsize, 1);
|
||||
buffer = xirealloc (buffer, ++bufsize);
|
||||
buffer[buflen] = 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user