From: Paul Eggert Date: Fri, 1 Nov 2024 16:40:36 +0000 (-0700) Subject: Prefer off_t to uintmax_t for continued_file_* X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d68c37b6407f265068c4335571e5be0f99e50ae6;p=thirdparty%2Ftar.git Prefer off_t to uintmax_t for continued_file_* * src/buffer.c (continued_file_size, continued_file_offset): Now off_t, not uintmax_t. All uses changed. * src/common.h (UINTMAX_FROM_HEADER): * src/list.c (uintmax_from_header): Remove; unused. * src/list.c (simple_print_header): * src/xheader.c (volume_size_decoder, volume_offset_decoder): Treat offset as off_t, not uintmax_t. --- diff --git a/src/buffer.c b/src/buffer.c index 108a4a68..ec0da361 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -97,8 +97,8 @@ static void (*flush_read_ptr) (void); char *volume_label; char *continued_file_name; -uintmax_t continued_file_size; -uintmax_t continued_file_offset; +off_t continued_file_size; +off_t continued_file_offset; static int volno = 1; /* which volume of a multi-volume tape we're @@ -1523,9 +1523,9 @@ try_new_volume (void) tar_stat_destroy (&dummy); ASSIGN_STRING_N (&continued_file_name, current_header->header.name); continued_file_size = - UINTMAX_FROM_HEADER (current_header->header.size); + OFF_FROM_HEADER (current_header->header.size); continued_file_offset = - UINTMAX_FROM_HEADER (current_header->oldgnu_header.offset); + OFF_FROM_HEADER (current_header->oldgnu_header.offset); break; default: @@ -1559,25 +1559,25 @@ try_new_volume (void) } } - uintmax_t s; + off_t s; if (ckd_add (&s, continued_file_size, continued_file_offset) || s != bufmap_head->sizetotal) { - paxwarn (0, _("%s is the wrong size (%jd != %ju + %ju)"), + paxwarn (0, _("%s is the wrong size (%jd != %jd + %jd)"), quote (continued_file_name), intmax (bufmap_head->sizetotal), - uintmax (continued_file_size), - uintmax (continued_file_offset)); + intmax (continued_file_size), + intmax (continued_file_offset)); return false; } if (bufmap_head->sizetotal - bufmap_head->sizeleft != continued_file_offset) { - paxwarn (0, _("This volume is out of sequence (%jd - %jd != %ju)"), + paxwarn (0, _("This volume is out of sequence (%jd - %jd != %jd)"), intmax (bufmap_head->sizetotal), intmax (bufmap_head->sizeleft), - uintmax (continued_file_offset)); + intmax (continued_file_offset)); return false; } } diff --git a/src/common.h b/src/common.h index 9e99c235..4394f50b 100644 --- a/src/common.h +++ b/src/common.h @@ -433,8 +433,8 @@ extern FILE *stdlis; extern bool write_archive_to_stdout; extern char *volume_label; extern char *continued_file_name; -extern uintmax_t continued_file_size; -extern uintmax_t continued_file_offset; +extern off_t continued_file_size; +extern off_t continued_file_offset; extern off_t records_written; extern union block *record_start; extern union block *record_end; @@ -606,10 +606,7 @@ void transform_stat_info (int typeflag, struct tar_stat_info *stat_info); char const *tartime (struct timespec t, bool full_time); #define OFF_FROM_HEADER(where) off_from_header (where, sizeof (where)) -#define UINTMAX_FROM_HEADER(where) uintmax_from_header (where, sizeof (where)) - off_t off_from_header (const char *buf, idx_t size); -uintmax_t uintmax_from_header (const char *buf, idx_t size); void list_archive (void); void test_archive_label (void); diff --git a/src/list.c b/src/list.c index 0cb561f5..5ff657e3 100644 --- a/src/list.c +++ b/src/list.c @@ -1003,12 +1003,6 @@ uid_from_header (const char *p, idx_t s) false, false); } -uintmax_t -uintmax_from_header (const char *p, idx_t s) -{ - return from_header (p, s, "uintmax_t", 0, UINTMAX_MAX, false, false); -} - /* Return a printable representation of T. The result points to static storage that can be reused in the next call to this @@ -1294,8 +1288,8 @@ simple_print_header (struct tar_stat_info *st, union block *blk, break; case GNUTYPE_MULTIVOL: - fprintf (stdlis, _("--Continued at byte %ju--\n"), - UINTMAX_FROM_HEADER (blk->oldgnu_header.offset)); + fprintf (stdlis, _("--Continued at byte %jd--\n"), + intmax (OFF_FROM_HEADER (blk->oldgnu_header.offset))); break; } } diff --git a/src/xheader.c b/src/xheader.c index 289f386e..91c84805 100644 --- a/src/xheader.c +++ b/src/xheader.c @@ -1530,7 +1530,7 @@ volume_size_decoder (MAYBE_UNUSED struct tar_stat_info *st, char const *arg, MAYBE_UNUSED idx_t size) { uintmax_t u; - if (decode_num (&u, arg, TYPE_MAXIMUM (uintmax_t), keyword)) + if (decode_num (&u, arg, TYPE_MAXIMUM (off_t), keyword)) continued_file_size = u; } @@ -1550,7 +1550,7 @@ volume_offset_decoder (MAYBE_UNUSED struct tar_stat_info *st, char const *arg, MAYBE_UNUSED idx_t size) { uintmax_t u; - if (decode_num (&u, arg, TYPE_MAXIMUM (uintmax_t), keyword)) + if (decode_num (&u, arg, TYPE_MAXIMUM (off_t), keyword)) continued_file_offset = u; }