]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: remove unnecessary uintmaxtostr usage in printf
authorCollin Funk <collin.funk1@gmail.com>
Wed, 17 Sep 2025 02:43:46 +0000 (19:43 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Wed, 17 Sep 2025 02:43:46 +0000 (19:43 -0700)
* src/comm.c (compare_files): Use the "%ju" printf directive instead of
"%s" and printing the result of umaxtostr.
* src/df.c (get_header): Likewise.
* src/ls.c (print_long_format): Likewise.
* src/sort.c (check): Likewise.

src/comm.c
src/df.c
src/ls.c
src/sort.c

index dd61dd9c8023d36e833c62580f22259392847344..6ebf66f380d473959ebe3cb3f5dfad55884dc423 100644 (file)
@@ -388,23 +388,20 @@ compare_files (char **infiles)
   if (total_option)
     {
       /* Print the summary, minding the column and line delimiters.  */
-      char buf1[INT_BUFSIZE_BOUND (uintmax_t)];
-      char buf2[INT_BUFSIZE_BOUND (uintmax_t)];
-      char buf3[INT_BUFSIZE_BOUND (uintmax_t)];
       if (col_sep_len == 1)
         { /* Separate to handle NUL char.  */
-          printf ("%s%c%s%c%s%c%s%c",
-                  umaxtostr (total[0], buf1), *col_sep,
-                  umaxtostr (total[1], buf2), *col_sep,
-                  umaxtostr (total[2], buf3), *col_sep,
+          printf ("%ju%c%ju%c%ju%c%s%c",
+                  total[0], *col_sep,
+                  total[1], *col_sep,
+                  total[2], *col_sep,
                   _("total"), delim);
         }
       else
         {
-          printf ("%s%s%s%s%s%s%s%c",
-                  umaxtostr (total[0], buf1), col_sep,
-                  umaxtostr (total[1], buf2), col_sep,
-                  umaxtostr (total[2], buf3), col_sep,
+          printf ("%ju%s%ju%s%ju%s%s%c",
+                  total[0], col_sep,
+                  total[1], col_sep,
+                  total[2], col_sep,
                   _("total"), delim);
         }
     }
index 77576513ea4d233630a1bc0580f4a655c618823e..5e369830fc0a52555aae351a06696433a240a777 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -617,11 +617,8 @@ get_header (void)
         }
       else if (header_mode == POSIX_MODE && columns[col]->field == SIZE_FIELD)
         {
-          char buf[INT_BUFSIZE_BOUND (uintmax_t)];
-          char *num = umaxtostr (output_block_size, buf);
-
           /* TRANSLATORS: this is the "1024-blocks" header in "df -P".  */
-          cell = xasprintf (_("%s-%s"), num, header);
+          cell = xasprintf (_("%ju-%s"), output_block_size, header);
         }
       else
         cell = xstrdup (header);
index 498ae3d73d4efc0a055bd6078ea2eeae340e401c..323b1db10e2b271e3cbea7f46a25984cfa870d87 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -4397,16 +4397,14 @@ print_long_format (const struct fileinfo *f)
   if (f->stat_ok
       && (S_ISCHR (f->stat.st_mode) || S_ISBLK (f->stat.st_mode)))
     {
-      char majorbuf[INT_BUFSIZE_BOUND (uintmax_t)];
-      char minorbuf[INT_BUFSIZE_BOUND (uintmax_t)];
       int blanks_width = (file_size_width
                           - (major_device_number_width + 2
                              + minor_device_number_width));
-      p += sprintf (p, "%*s, %*s ",
+      p += sprintf (p, "%*ju, %*ju ",
                     major_device_number_width + MAX (0, blanks_width),
-                    umaxtostr (major (f->stat.st_rdev), majorbuf),
+                    (uintmax_t) major (f->stat.st_rdev),
                     minor_device_number_width,
-                    umaxtostr (minor (f->stat.st_rdev), minorbuf));
+                    (uintmax_t) minor (f->stat.st_rdev));
     }
   else
     {
index 8363d2d1d921e5a9fb0c5d010da5cb4c44fd63bc..a4d81bc1c822ba2c8c1e9a85eeedab8f40f61eb7 100644 (file)
@@ -2997,10 +2997,8 @@ check (char const *file_name, char checkonly)
                 struct line const *disorder_line = line - 1;
                 uintmax_t disorder_line_number =
                   buffer_linelim (&buf) - disorder_line + line_number;
-                char hr_buf[INT_BUFSIZE_BOUND (disorder_line_number)];
-                fprintf (stderr, _("%s: %s:%s: disorder: "),
-                         program_name, file_name,
-                         umaxtostr (disorder_line_number, hr_buf));
+                fprintf (stderr, _("%s: %s:%ju: disorder: "),
+                         program_name, file_name, disorder_line_number);
                 write_line (disorder_line, stderr, _("standard error"));
               }