]> Dogcows Code - chaz/tar/commitdiff
(append_file) Use off_t, size_t, ssize_t when appropriate. Remove
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 31 Oct 1997 00:58:55 +0000 (00:58 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 31 Oct 1997 00:58:55 +0000 (00:58 +0000)
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.

src/update.c

index a78b9775e168a2f23e196e6eeabf08f8ae86e2ba..b8398724616b85f50d7d38f9220d100b210b08d1 100644 (file)
@@ -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);
       }
   }
 
This page took 0.023447 seconds and 4 git commands to generate.