From: Paul Eggert Date: Fri, 31 Oct 1997 00:58:55 +0000 (+0000) Subject: (append_file) Use off_t, size_t, ssize_t when appropriate. Remove X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=ac65803ac9356b844e38d11f4c3c51ba4cfb0978;p=chaz%2Ftar (append_file) Use off_t, size_t, ssize_t when appropriate. Remove now-useless casts. Use unsigned long to print *_t types, except use STRINGIFY_BIGINT for off_t. (update_archive): Cast -1 to dev_t when necessary. --- diff --git a/src/update.c b/src/update.c index a78b977..b839872 100644 --- a/src/update.c +++ b/src/update.c @@ -47,7 +47,7 @@ append_file (char *path) { int handle; struct stat stat_data; - long bytes_left; + off_t bytes_left; if (stat (path, &stat_data) != 0 || (handle = open (path, O_RDONLY | O_BINARY), handle < 0)) @@ -61,8 +61,8 @@ append_file (char *path) while (bytes_left > 0) { union block *start = find_next_block (); - long buffer_size = available_space_after (start); - int status; + size_t buffer_size = available_space_after (start); + ssize_t status; if (bytes_left < buffer_size) { @@ -73,18 +73,25 @@ append_file (char *path) (size_t) (BLOCKSIZE - status)); } - status = read (handle, start->buffer, (size_t) buffer_size); + status = read (handle, start->buffer, buffer_size); if (status < 0) - FATAL_ERROR ((0, errno, - _("Read error at byte %ld reading %d bytes in file %s"), - stat_data.st_size - bytes_left, buffer_size, path)); + { + char buf[UINTMAX_STRSIZE_BOUND]; + FATAL_ERROR ((0, errno, + _("Read error at byte %s reading %lu bytes in file %s"), + STRINGIFY_BIGINT (stat_data.st_size - bytes_left, buf), + (unsigned long) buffer_size, path)); + } bytes_left -= status; set_next_block_after (start + (status - 1) / BLOCKSIZE); if (status != buffer_size) - FATAL_ERROR ((0, 0, _("%s: File shrunk by %d bytes, (yark!)"), - path, bytes_left)); + { + char buf[UINTMAX_STRSIZE_BOUND]; + FATAL_ERROR ((0, 0, _("%s: File shrunk by %s bytes, (yark!)"), + path, STRINGIFY_BIGINT (bytes_left, buf))); + } } close (handle); @@ -135,7 +142,7 @@ update_archive (void) set_next_block_after (current_header); if (current_header->oldgnu_header.isextended) skip_extended_headers (); - skip_file ((long) current_stat.st_size); + skip_file (current_stat.st_size); break; } @@ -187,7 +194,7 @@ update_archive (void) if (subcommand_option == CAT_SUBCOMMAND) append_file (path); else - dump_file (path, -1, 1); + dump_file (path, (dev_t) -1, 1); } }