From: Paul Eggert Date: Fri, 19 Nov 2021 05:36:47 +0000 (-0800) Subject: maint: prefer MAYBE_UNUSED X-Git-Tag: v9.1~179 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e2d64448300ea91be258af5b64ed3b97b865bd6;p=thirdparty%2Fcoreutils.git maint: prefer MAYBE_UNUSED Prefer MAYBE_UNUSED to _GL_UNUSED, since the C2x syntax will be [[maybe_unused]] at the start of the declaration, and we want to look forward to that. All uses of _GL_UNUSED either changed to MAYBE_UNUSED, or (when not needed) removed. --- diff --git a/src/chroot.c b/src/chroot.c index 9a0cd2a5bf..e5aa7c0b2c 100644 --- a/src/chroot.c +++ b/src/chroot.c @@ -67,7 +67,7 @@ static struct option const long_opts[] = #if ! HAVE_SETGROUPS /* At least Interix lacks supplemental group support. */ static int -setgroups (size_t size, gid_t const *list _GL_UNUSED) +setgroups (size_t size, MAYBE_UNUSED gid_t const *list) { if (size == 0) { diff --git a/src/cksum.c b/src/cksum.c index 51afe89f68..2209807cb3 100644 --- a/src/cksum.c +++ b/src/cksum.c @@ -286,8 +286,7 @@ crc_sum_stream (FILE *stream, void *resstream, uintmax_t *length) void output_crc (char const *file, int binary_file, void const *digest, - bool tagged, unsigned char delim, bool args _GL_UNUSED, - uintmax_t length _GL_UNUSED) + bool tagged, unsigned char delim, bool args, uintmax_t length) { char length_buf[INT_BUFSIZE_BOUND (uintmax_t)]; printf ("%u %s", *(unsigned int *)digest, umaxtostr (length, length_buf)); diff --git a/src/cksum.h b/src/cksum.h index 8e9be44391..28d72ee247 100644 --- a/src/cksum.h +++ b/src/cksum.h @@ -8,8 +8,7 @@ crc_sum_stream (FILE *stream, void *resstream, uintmax_t *length); extern void output_crc (char const *file, int binary_file, void const *digest, - bool tagged, unsigned char delim, bool args _GL_UNUSED, - uintmax_t length _GL_UNUSED) + bool tagged, unsigned char delim, bool args, uintmax_t length) _GL_ATTRIBUTE_NONNULL ((3)); extern bool diff --git a/src/copy.c b/src/copy.c index 196c781040..ba46cd3b7f 100644 --- a/src/copy.c +++ b/src/copy.c @@ -669,7 +669,7 @@ errno_unsupported (int err) #if USE_XATTR ATTRIBUTE_FORMAT ((printf, 2, 3)) static void -copy_attr_error (struct error_context *ctx _GL_UNUSED, +copy_attr_error (MAYBE_UNUSED struct error_context *ctx, char const *fmt, ...) { if (!errno_unsupported (errno)) @@ -686,7 +686,7 @@ copy_attr_error (struct error_context *ctx _GL_UNUSED, ATTRIBUTE_FORMAT ((printf, 2, 3)) static void -copy_attr_allerror (struct error_context *ctx _GL_UNUSED, +copy_attr_allerror (MAYBE_UNUSED struct error_context *ctx, char const *fmt, ...) { int err = errno; @@ -699,14 +699,14 @@ copy_attr_allerror (struct error_context *ctx _GL_UNUSED, } static char const * -copy_attr_quote (struct error_context *ctx _GL_UNUSED, char const *str) +copy_attr_quote (MAYBE_UNUSED struct error_context *ctx, char const *str) { return quoteaf (str); } static void -copy_attr_free (struct error_context *ctx _GL_UNUSED, - char const *str _GL_UNUSED) +copy_attr_free (MAYBE_UNUSED struct error_context *ctx, + MAYBE_UNUSED char const *str) { } @@ -759,11 +759,11 @@ copy_attr (char const *src_path, int src_fd, #else /* USE_XATTR */ static bool -copy_attr (char const *src_path _GL_UNUSED, - int src_fd _GL_UNUSED, - char const *dst_path _GL_UNUSED, - int dst_fd _GL_UNUSED, - struct cp_options const *x _GL_UNUSED) +copy_attr (MAYBE_UNUSED char const *src_path, + MAYBE_UNUSED int src_fd, + MAYBE_UNUSED char const *dst_path, + MAYBE_UNUSED int dst_fd, + MAYBE_UNUSED struct cp_options const *x) { return true; } diff --git a/src/digest.c b/src/digest.c index 62ed795c18..85e2909b4b 100644 --- a/src/digest.c +++ b/src/digest.c @@ -167,8 +167,8 @@ #if !HASH_ALGO_SUM static void output_file (char const *file, int binary_file, void const *digest, - bool tagged, unsigned char delim, bool args _GL_UNUSED, - uintmax_t length _GL_UNUSED); + bool tagged, unsigned char delim, bool args, + uintmax_t length); #endif /* True if any of the files read were the standard input. */ @@ -902,7 +902,7 @@ print_filename (char const *file, bool escape) static bool digest_file (char const *filename, int *binary, unsigned char *bin_result, - bool *missing, uintmax_t* length _GL_UNUSED) + bool *missing, MAYBE_UNUSED uintmax_t *length) { FILE *fp; int err; @@ -968,8 +968,8 @@ digest_file (char const *filename, int *binary, unsigned char *bin_result, #if !HASH_ALGO_SUM static void output_file (char const *file, int binary_file, void const *digest, - bool tagged, unsigned char delim, bool args _GL_UNUSED, - uintmax_t length _GL_UNUSED) + bool tagged, unsigned char delim, MAYBE_UNUSED bool args, + MAYBE_UNUSED uintmax_t length) { unsigned char const *bin_buffer = digest; diff --git a/src/factor.c b/src/factor.c index 614f8fa15c..caa97cbd27 100644 --- a/src/factor.c +++ b/src/factor.c @@ -776,7 +776,8 @@ factor_using_division (uintmax_t *t1p, uintmax_t t1, uintmax_t t0, { for (;;) { - uintmax_t q1, q0, hi, lo _GL_UNUSED; + uintmax_t q1, q0, hi; + MAYBE_UNUSED uintmax_t lo; q0 = t0 * primes_dtab[i].binv; umul_ppmm (hi, lo, q0, p); @@ -916,7 +917,8 @@ static const unsigned char binvert_table[128] = _q0 = (u0) * _di; \ if ((u1) >= (d)) \ { \ - uintmax_t _p1, _p0 _GL_UNUSED; \ + uintmax_t _p1; \ + MAYBE_UNUSED intmax_t _p0; \ umul_ppmm (_p1, _p0, _q0, d); \ (q1) = ((u1) - _p1) * _di; \ (q0) = _q0; \ @@ -931,7 +933,7 @@ static const unsigned char binvert_table[128] = /* x B (mod n). */ #define redcify(r_prim, r, n) \ do { \ - uintmax_t _redcify_q _GL_UNUSED; \ + MAYBE_UNUSED uintmax_t _redcify_q; \ udiv_qrnnd (_redcify_q, r_prim, r, 0, n); \ } while (0) @@ -964,7 +966,8 @@ static const unsigned char binvert_table[128] = static inline uintmax_t mulredc (uintmax_t a, uintmax_t b, uintmax_t m, uintmax_t mi) { - uintmax_t rh, rl, q, th, tl _GL_UNUSED, xh; + uintmax_t rh, rl, q, th, xh; + MAYBE_UNUSED uintmax_t tl; umul_ppmm (rh, rl, a, b); q = rl * mi; @@ -984,7 +987,8 @@ mulredc2 (uintmax_t *r1p, uintmax_t a1, uintmax_t a0, uintmax_t b1, uintmax_t b0, uintmax_t m1, uintmax_t m0, uintmax_t mi) { - uintmax_t r1, r0, q, p1, p0 _GL_UNUSED, t1, t0, s1, s0; + uintmax_t r1, r0, q, p1, t1, t0, s1, s0; + MAYBE_UNUSED uintmax_t p0; mi = -mi; assert ((a1 >> (W_TYPE_SIZE - 1)) == 0); assert ((b1 >> (W_TYPE_SIZE - 1)) == 0); @@ -1254,7 +1258,7 @@ prime_p (uintmax_t n) a_prim = s0 % n; else { - uintmax_t dummy _GL_UNUSED; + MAYBE_UNUSED uintmax_t dummy; udiv_qrnnd (dummy, a_prim, s1, s0, n); } } @@ -1802,7 +1806,7 @@ isqrt2 (uintmax_t nh, uintmax_t nl) /* Do we need more than one iteration? */ for (;;) { - uintmax_t r _GL_UNUSED; + MAYBE_UNUSED uintmax_t r; uintmax_t q, y; udiv_qrnnd (q, r, nh, nl, x); y = (x + q) / 2; diff --git a/src/ls.c b/src/ls.c index 992f604f45..77d94072b1 100644 --- a/src/ls.c +++ b/src/ls.c @@ -3177,7 +3177,7 @@ has_capability (char const *name) } #else static bool -has_capability (char const *name _GL_UNUSED) +has_capability (MAYBE_UNUSED char const *name) { errno = ENOTSUP; return false; diff --git a/src/od.c b/src/od.c index b4ae8490f2..645f71f3a3 100644 --- a/src/od.c +++ b/src/od.c @@ -427,10 +427,10 @@ Binary prefixes can be used, too: KiB=K, MiB=M, and so on.\n\ /* Define the print functions. */ -#define PRINT_FIELDS(N, T, FMT_STRING, ACTION) \ +#define PRINT_FIELDS(N, T, FMT_STRING_DECL, ACTION) \ static void \ N (size_t fields, size_t blank, void const *block, \ - char const *FMT_STRING, int width, int pad) \ + FMT_STRING_DECL, int width, int pad) \ { \ T const *p = block; \ uintmax_t i; \ @@ -460,10 +460,11 @@ N (size_t fields, size_t blank, void const *block, \ } #define PRINT_TYPE(N, T) \ - PRINT_FIELDS (N, T, fmt_string, xprintf (fmt_string, adjusted_width, x)) + PRINT_FIELDS (N, T, char const *fmt_string, \ + xprintf (fmt_string, adjusted_width, x)) #define PRINT_FLOATTYPE(N, T, FTOASTR, BUFSIZE) \ - PRINT_FIELDS (N, T, fmt_string _GL_UNUSED, \ + PRINT_FIELDS (N, T, MAYBE_UNUSED char const *fmt_string, \ char buf[BUFSIZE]; \ FTOASTR (buf, sizeof buf, 0, 0, x); \ xprintf ("%*s", adjusted_width, buf)) @@ -498,7 +499,7 @@ dump_hexl_mode_trailer (size_t n_bytes, char const *block) static void print_named_ascii (size_t fields, size_t blank, void const *block, - char const *unused_fmt_string _GL_UNUSED, + MAYBE_UNUSED char const *unused_fmt_string, int width, int pad) { unsigned char const *p = block; @@ -529,7 +530,7 @@ print_named_ascii (size_t fields, size_t blank, void const *block, static void print_ascii (size_t fields, size_t blank, void const *block, - char const *unused_fmt_string _GL_UNUSED, int width, + MAYBE_UNUSED char const *unused_fmt_string, int width, int pad) { unsigned char const *p = block; @@ -1112,8 +1113,8 @@ skip (uintmax_t n_skip) } static void -format_address_none (uintmax_t address _GL_UNUSED, - char c _GL_UNUSED) +format_address_none (MAYBE_UNUSED uintmax_t address, + MAYBE_UNUSED char c) { } diff --git a/src/stat.c b/src/stat.c index 280142b5ce..7849b54dc2 100644 --- a/src/stat.c +++ b/src/stat.c @@ -860,7 +860,7 @@ out_file_context (char *pformat, size_t prefix_len, char const *filename) /* Print statfs info. Return zero upon success, nonzero upon failure. */ NODISCARD static bool -print_statfs (char *pformat, size_t prefix_len, char mod _GL_UNUSED, char m, +print_statfs (char *pformat, size_t prefix_len, MAYBE_UNUSED char mod, char m, int fd, char const *filename, void const *data) { diff --git a/src/stty.c b/src/stty.c index 9b10eb1eec..fa5a0dc546 100644 --- a/src/stty.c +++ b/src/stty.c @@ -1274,7 +1274,7 @@ main (int argc, char **argv) int argi = 0; int opti = 1; bool require_set_attr; - bool speed_was_set _GL_UNUSED; + MAYBE_UNUSED bool speed_was_set; bool verbose_output; bool recoverable_output; bool noargs = true; diff --git a/src/sum.c b/src/sum.c index 3c5e687db5..c9713ca8b9 100644 --- a/src/sum.c +++ b/src/sum.c @@ -184,8 +184,8 @@ cleanup_buffer: void output_bsd (char const *file, int binary_file, void const *digest, - bool tagged, unsigned char delim, bool args _GL_UNUSED, - uintmax_t length _GL_UNUSED) + bool tagged, unsigned char delim, bool args, + uintmax_t length) { char hbuf[LONGEST_HUMAN_READABLE + 1]; @@ -201,8 +201,8 @@ output_bsd (char const *file, int binary_file, void const *digest, void output_sysv (char const *file, int binary_file, void const *digest, - bool tagged, unsigned char delim, bool args _GL_UNUSED, - uintmax_t length _GL_UNUSED) + bool tagged, unsigned char delim, bool args, + uintmax_t length) { char hbuf[LONGEST_HUMAN_READABLE + 1]; diff --git a/src/sum.h b/src/sum.h index 1681697aba..7e46b871ce 100644 --- a/src/sum.h +++ b/src/sum.h @@ -9,10 +9,10 @@ typedef int (*sumfn)(FILE *, void *, uintmax_t*); extern void output_bsd (char const *file, int binary_file, void const *digest, - bool tagged, unsigned char delim, bool args _GL_UNUSED, - uintmax_t length _GL_UNUSED); + bool tagged, unsigned char delim, bool args, + uintmax_t length); extern void output_sysv (char const *file, int binary_file, void const *digest, - bool tagged, unsigned char delim, bool args _GL_UNUSED, - uintmax_t length _GL_UNUSED); + bool tagged, unsigned char delim, bool args, + uintmax_t length); diff --git a/src/tac.c b/src/tac.c index cbc3deac99..f40a9c0fe9 100644 --- a/src/tac.c +++ b/src/tac.c @@ -417,7 +417,7 @@ record_or_unlink_tempfile (char const *fn, FILE *fp) #else static void -record_or_unlink_tempfile (char const *fn, FILE *fp _GL_UNUSED) +record_or_unlink_tempfile (char const *fn, MAYBE_UNUSED FILE *fp) { unlink (fn); } diff --git a/src/tsort.c b/src/tsort.c index de45823035..c685345a35 100644 --- a/src/tsort.c +++ b/src/tsort.c @@ -285,7 +285,7 @@ record_relation (struct item *j, struct item *k) } static bool -count_items (struct item *unused _GL_UNUSED) +count_items (MAYBE_UNUSED struct item *unused) { n_strings++; return false;