]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: adjust INT_BUFSIZE_BOUND usage for maintainability
authorJim Meyering <meyering@redhat.com>
Mon, 7 Jun 2010 05:15:15 +0000 (07:15 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 8 Jun 2010 11:16:26 +0000 (13:16 +0200)
* src/tail.c (xlseek): Give INT_BUFSIZE_BOUND a variable name,
not a type name.
* src/ls.c (gobble_file, format_user_or_group_width): Likewise.
* src/head.c (elide_tail_bytes_pipe): Likewise.
(elide_tail_lines_seekable, main): Likewise.
[This change is not complete -- there are doubtless other uses
that can be updated in the same way.]

src/head.c
src/ls.c
src/tail.c

index 7fa5823eb3e03b304bcaf027871fe7c804dd6882..dd3dc894c40dd16cf6c0f3d8f4c2b744aea7244c 100644 (file)
@@ -226,7 +226,7 @@ elide_tail_bytes_pipe (const char *filename, int fd, uintmax_t n_elide_0)
 
   if (SIZE_MAX < n_elide_0 + READ_BUFSIZE)
     {
-      char umax_buf[INT_BUFSIZE_BOUND (uintmax_t)];
+      char umax_buf[INT_BUFSIZE_BOUND (n_elide_0)];
       error (EXIT_FAILURE, 0, _("%s: number of bytes is too large"),
              umaxtostr (n_elide_0, umax_buf));
     }
@@ -611,7 +611,7 @@ elide_tail_lines_seekable (const char *pretty_filename, int fd,
   pos -= bytes_read;
   if (lseek (fd, pos, SEEK_SET) < 0)
     {
-      char offset_buf[INT_BUFSIZE_BOUND (off_t)];
+      char offset_buf[INT_BUFSIZE_BOUND (pos)];
       error (0, errno, _("%s: cannot seek to offset %s"),
              pretty_filename, offtostr (pos, offset_buf));
       return false;
@@ -682,7 +682,7 @@ elide_tail_lines_seekable (const char *pretty_filename, int fd,
       pos -= BUFSIZ;
       if (lseek (fd, pos, SEEK_SET) < 0)
         {
-          char offset_buf[INT_BUFSIZE_BOUND (off_t)];
+          char offset_buf[INT_BUFSIZE_BOUND (pos)];
           error (0, errno, _("%s: cannot seek to offset %s"),
                  pretty_filename, offtostr (pos, offset_buf));
           return false;
@@ -1042,7 +1042,7 @@ main (int argc, char **argv)
 
   if ( ! count_lines && elide_from_end && OFF_T_MAX < n_units)
     {
-      char umax_buf[INT_BUFSIZE_BOUND (uintmax_t)];
+      char umax_buf[INT_BUFSIZE_BOUND (n_units)];
       error (EXIT_FAILURE, 0, _("%s: number of bytes is too large"),
              umaxtostr (n_units, umax_buf));
     }
index 954913085e84d6c3a30fc38c48f02cd15c75812c..4e0a036c8b844753fd5a35cb6eaeabcfb21da875 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -2986,7 +2986,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
 
       if (format == long_format)
         {
-          char b[INT_BUFSIZE_BOUND (uintmax_t)];
+          char b[INT_BUFSIZE_BOUND (f->stat.st_nlink)];
           int b_len = strlen (umaxtostr (f->stat.st_nlink, b));
           if (nlink_width < b_len)
             nlink_width = b_len;
@@ -3582,7 +3582,7 @@ format_user_or_group_width (char const *name, unsigned long int id)
     }
   else
     {
-      char buf[INT_BUFSIZE_BOUND (unsigned long int)];
+      char buf[INT_BUFSIZE_BOUND (id)];
       sprintf (buf, "%lu", id);
       return strlen (buf);
     }
index 9e95dee7e64bea36553ffeb704f8e3618abd6efe..75e9d53e3985542ba333e6abb5e13b7ff0ffa7a1 100644 (file)
@@ -434,7 +434,7 @@ static off_t
 xlseek (int fd, off_t offset, int whence, char const *filename)
 {
   off_t new_offset = lseek (fd, offset, whence);
-  char buf[INT_BUFSIZE_BOUND (off_t)];
+  char buf[INT_BUFSIZE_BOUND (offset)];
   char *s;
 
   if (0 <= new_offset)