]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Prefer off_t to uintmax_t for continued_file_*
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 1 Nov 2024 16:40:36 +0000 (09:40 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 2 Nov 2024 06:47:23 +0000 (23:47 -0700)
* 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.

src/buffer.c
src/common.h
src/list.c
src/xheader.c

index 108a4a6876c5eb78b0046e52a1ea193a9acc5926..ec0da361a38e4341eaea927a977fec5910ad1c9e 100644 (file)
@@ -97,8 +97,8 @@ static void (*flush_read_ptr) (void);
 \f
 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;
 
 \f
 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;
         }
     }
index 9e99c235cbd7c6a2a72e30ffab56d6901dde0563..4394f50bdd8d7c04313b9d448cf12d724766c9f3 100644 (file)
@@ -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);
index 0cb561f553aae7398a95df1419d6df4361f54ea7..5ff657e300ffcb1e2d9d2ded282e0abcae8aa836 100644 (file)
@@ -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;
        }
     }
index 289f386ed3716e5bedd245a38621451f08d353f4..91c84805f140b98684160540c618c075f24ed44c 100644 (file)
@@ -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;
 }