From: Collin Funk Date: Wed, 17 Sep 2025 02:43:46 +0000 (-0700) Subject: maint: remove unnecessary uintmaxtostr usage in printf X-Git-Tag: v9.8~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1efb539630d6fd45e2c92f094471d3760f5b6836;p=thirdparty%2Fcoreutils.git maint: remove unnecessary uintmaxtostr usage in printf * 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. --- diff --git a/src/comm.c b/src/comm.c index dd61dd9c80..6ebf66f380 100644 --- a/src/comm.c +++ b/src/comm.c @@ -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); } } diff --git a/src/df.c b/src/df.c index 77576513ea..5e369830fc 100644 --- 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); diff --git a/src/ls.c b/src/ls.c index 498ae3d73d..323b1db10e 100644 --- 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 { diff --git a/src/sort.c b/src/sort.c index 8363d2d1d9..a4d81bc1c8 100644 --- a/src/sort.c +++ b/src/sort.c @@ -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")); }