From: Pádraig Brady Date: Tue, 19 Feb 2013 10:58:51 +0000 (+0000) Subject: maint: cleanup up various uses of __attribute__ X-Git-Tag: v8.22~190 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31861f663a440df498bdb7788fa43aa9d03133c5;p=thirdparty%2Fcoreutils.git maint: cleanup up various uses of __attribute__ * src/cfg.mk (sc_prohibit-gl-attributes): Disallow the __attribute() form without trailing underscores as that is not elided where required. Also ensure we use gnulib macros rather than defining our own. * src/system.h: Remove gnulib provided macros. * src/chown-core.c: Likewise. * src/chroot.c: Likewise. * src/copy.c: Likewise. * src/csplit.c: Likewise. * src/dd.c: Likewise. * src/expr.c: Likewise. * src/extent-scan.c: Likewise. * src/factor.c: Likewise. * src/ls.c: Likewise. * src/od.c: Likewise. * src/paste.c: Likewise. * src/ptx.c: Likewise. * src/sort.c: Likewise. * src/stat.c: Likewise. * src/stty.c: Likewise. * src/system.h: Likewise. * src/tac.c: Likewise. * src/test.c: Likewise. * src/tsort.c: Likewise. --- diff --git a/cfg.mk b/cfg.mk index c9952d2c0c..6fa7b1f728 100644 --- a/cfg.mk +++ b/cfg.mk @@ -201,6 +201,16 @@ sc_prohibit-j-printf-format: && { echo '$(ME): Use PRI*MAX instead of %j' 1>&2; exit 1; } \ || : +# Ensure the alternative __attribute (keyword) form isn't used as +# that form is not elided where required. Also ensure that we don't +# directly use attributes already defined by gnulib. +# TODO: move the check for _GL... attributes to gnulib. +sc_prohibit-gl-attributes: + @cd $(srcdir) && GIT_PAGER= git grep -En \ + "__attribute |__(unused|pure|const)__" src gl/lib/*.[ch] \ + && { echo '$(ME): Use _GL... attribute macros' 1>&2; exit 1; } \ + || : + # Look for lines longer than 80 characters, except omit: # - program-generated long lines in diff headers, # - tests involving long checksum lines, and diff --git a/src/chown-core.c b/src/chown-core.c index 3a3044e04f..a5a2b4761e 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -68,7 +68,7 @@ chopt_init (struct Chown_option *chopt) } extern void -chopt_free (struct Chown_option *chopt ATTRIBUTE_UNUSED) +chopt_free (struct Chown_option *chopt _GL_UNUSED) { /* Deliberately do not free chopt->user_name or ->group_name. They're not always allocated. */ diff --git a/src/chroot.c b/src/chroot.c index 1c1a976950..b77a8bf667 100644 --- a/src/chroot.c +++ b/src/chroot.c @@ -57,7 +57,7 @@ static struct option const long_opts[] = always-successful replacement to avoid checking for setgroups availability everywhere, just to support broken platforms. */ static int -setgroups (size_t size ATTRIBUTE_UNUSED, gid_t const *list ATTRIBUTE_UNUSED) +setgroups (size_t size _GL_UNUSED, gid_t const *list _GL_UNUSED) { return 0; } diff --git a/src/copy.c b/src/copy.c index 3f2cc2b0c2..244313ee70 100644 --- a/src/copy.c +++ b/src/copy.c @@ -471,7 +471,7 @@ errno_unsupported (int err) #if USE_XATTR static void -copy_attr_error (struct error_context *ctx ATTRIBUTE_UNUSED, +copy_attr_error (struct error_context *ctx _GL_UNUSED, char const *fmt, ...) { if (!errno_unsupported (errno)) @@ -487,7 +487,7 @@ copy_attr_error (struct error_context *ctx ATTRIBUTE_UNUSED, } static void -copy_attr_allerror (struct error_context *ctx ATTRIBUTE_UNUSED, +copy_attr_allerror (struct error_context *ctx _GL_UNUSED, char const *fmt, ...) { int err = errno; @@ -500,14 +500,14 @@ copy_attr_allerror (struct error_context *ctx ATTRIBUTE_UNUSED, } static char const * -copy_attr_quote (struct error_context *ctx ATTRIBUTE_UNUSED, char const *str) +copy_attr_quote (struct error_context *ctx _GL_UNUSED, char const *str) { return quote (str); } static void -copy_attr_free (struct error_context *ctx ATTRIBUTE_UNUSED, - char const *str ATTRIBUTE_UNUSED) +copy_attr_free (struct error_context *ctx _GL_UNUSED, + char const *str _GL_UNUSED) { } @@ -539,11 +539,11 @@ copy_attr (char const *src_path, int src_fd, #else /* USE_XATTR */ static bool -copy_attr (char const *src_path ATTRIBUTE_UNUSED, - int src_fd ATTRIBUTE_UNUSED, - char const *dst_path ATTRIBUTE_UNUSED, - int dst_fd ATTRIBUTE_UNUSED, - struct cp_options const *x ATTRIBUTE_UNUSED) +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) { return true; } diff --git a/src/extent-scan.c b/src/extent-scan.c index 5d25b9aaba..6d3032a727 100644 --- a/src/extent-scan.c +++ b/src/extent-scan.c @@ -218,7 +218,7 @@ extent_scan_read (struct extent_scan *scan) } #else extern bool -extent_scan_read (struct extent_scan *scan ATTRIBUTE_UNUSED) +extent_scan_read (struct extent_scan *scan _GL_UNUSED) { scan->initial_scan_failed = true; errno = ENOTSUP; diff --git a/src/factor.c b/src/factor.c index 8f1542a2f4..257a7ed90e 100644 --- a/src/factor.c +++ b/src/factor.c @@ -791,7 +791,7 @@ factor_using_division (uintmax_t *t1p, uintmax_t t1, uintmax_t t0, { for (;;) { - uintmax_t q1, q0, hi, lo ATTRIBUTE_UNUSED; + uintmax_t q1, q0, hi, lo _GL_UNUSED; q0 = t0 * primes_dtab[i].binv; umul_ppmm (hi, lo, q0, p); @@ -933,7 +933,7 @@ static const unsigned char binvert_table[128] = _q0 = (u0) * _di; \ if ((u1) >= (d)) \ { \ - uintmax_t _p1, _p0 ATTRIBUTE_UNUSED; \ + uintmax_t _p1, _p0 _GL_UNUSED; \ umul_ppmm (_p1, _p0, _q0, d); \ (q1) = ((u1) - _p1) * _di; \ (q0) = _q0; \ @@ -948,7 +948,7 @@ static const unsigned char binvert_table[128] = /* x B (mod n). */ #define redcify(r_prim, r, n) \ do { \ - uintmax_t _redcify_q ATTRIBUTE_UNUSED; \ + uintmax_t _redcify_q _GL_UNUSED; \ udiv_qrnnd (_redcify_q, r_prim, r, 0, n); \ } while (0) @@ -981,7 +981,7 @@ 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 ATTRIBUTE_UNUSED, xh; + uintmax_t rh, rl, q, th, tl _GL_UNUSED, xh; umul_ppmm (rh, rl, a, b); q = rl * mi; @@ -1001,7 +1001,7 @@ 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 ATTRIBUTE_UNUSED, t1, t0, s1, s0; + uintmax_t r1, r0, q, p1, p0 _GL_UNUSED, t1, t0, s1, s0; mi = -mi; assert ( (a1 >> (W_TYPE_SIZE - 1)) == 0); assert ( (b1 >> (W_TYPE_SIZE - 1)) == 0); @@ -1271,7 +1271,7 @@ prime_p (uintmax_t n) a_prim = s0 % n; else { - uintmax_t dummy ATTRIBUTE_UNUSED; + uintmax_t dummy _GL_UNUSED; udiv_qrnnd (dummy, a_prim, s1, s0, n); } } @@ -1803,7 +1803,7 @@ isqrt2 (uintmax_t nh, uintmax_t nl) /* Do we need more than one iteration? */ for (;;) { - uintmax_t r ATTRIBUTE_UNUSED; + uintmax_t r _GL_UNUSED; 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 f1ed43bd23..d9876f8427 100644 --- a/src/ls.c +++ b/src/ls.c @@ -2734,7 +2734,7 @@ has_capability (char const *name) } #else static bool -has_capability (char const *name ATTRIBUTE_UNUSED) +has_capability (char const *name _GL_UNUSED) { errno = ENOTSUP; return false; diff --git a/src/od.c b/src/od.c index ffccd7410a..e7d881b28e 100644 --- a/src/od.c +++ b/src/od.c @@ -416,7 +416,7 @@ N (size_t fields, size_t blank, void const *block, \ PRINT_FIELDS (N, T, fmt_string, xprintf (fmt_string, adjusted_width, x)) #define PRINT_FLOATTYPE(N, T, FTOASTR, BUFSIZE) \ - PRINT_FIELDS (N, T, fmt_string ATTRIBUTE_UNUSED, \ + PRINT_FIELDS (N, T, fmt_string _GL_UNUSED, \ char buf[BUFSIZE]; \ FTOASTR (buf, sizeof buf, 0, 0, x); \ xprintf ("%*s", adjusted_width, buf)) @@ -452,7 +452,7 @@ dump_hexl_mode_trailer (size_t n_bytes, const char *block) static void print_named_ascii (size_t fields, size_t blank, void const *block, - const char *unused_fmt_string ATTRIBUTE_UNUSED, + const char *unused_fmt_string _GL_UNUSED, int width, int pad) { unsigned char const *p = block; @@ -483,7 +483,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, - const char *unused_fmt_string ATTRIBUTE_UNUSED, int width, + const char *unused_fmt_string _GL_UNUSED, int width, int pad) { unsigned char const *p = block; @@ -1056,8 +1056,8 @@ skip (uintmax_t n_skip) } static void -format_address_none (uintmax_t address ATTRIBUTE_UNUSED, - char c ATTRIBUTE_UNUSED) +format_address_none (uintmax_t address _GL_UNUSED, + char c _GL_UNUSED) { } diff --git a/src/stat.c b/src/stat.c index dd210d181c..232669811f 100644 --- a/src/stat.c +++ b/src/stat.c @@ -583,7 +583,7 @@ out_minus_zero (char *pformat, size_t prefix_len) acts like printf's %f format. */ static void out_epoch_sec (char *pformat, size_t prefix_len, - struct stat const *statbuf ATTRIBUTE_UNUSED, + struct stat const *statbuf _GL_UNUSED, struct timespec arg) { char *dot = memchr (pformat, '.', prefix_len); diff --git a/src/stty.c b/src/stty.c index ee891a5933..e518839d58 100644 --- a/src/stty.c +++ b/src/stty.c @@ -745,7 +745,7 @@ main (int argc, char **argv) int argi = 0; int opti = 1; bool require_set_attr; - bool speed_was_set ATTRIBUTE_UNUSED; + bool speed_was_set _GL_UNUSED; bool verbose_output; bool recoverable_output; int k; diff --git a/src/system.h b/src/system.h index 1677999ef7..0605a2f2e5 100644 --- a/src/system.h +++ b/src/system.h @@ -425,10 +425,6 @@ enum # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) #endif -#ifndef ATTRIBUTE_UNUSED -# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) -#endif - /* The warn_unused_result attribute appeared first in gcc-3.4.0 */ #undef ATTRIBUTE_WARN_UNUSED_RESULT #if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) diff --git a/src/tac.c b/src/tac.c index c6a8cf6958..5bf40a7e85 100644 --- a/src/tac.c +++ b/src/tac.c @@ -409,7 +409,7 @@ record_or_unlink_tempfile (char const *fn, FILE *fp) #else static void -record_or_unlink_tempfile (char const *fn, FILE *fp ATTRIBUTE_UNUSED) +record_or_unlink_tempfile (char const *fn, FILE *fp _GL_UNUSED) { unlink (fn); } diff --git a/src/tsort.c b/src/tsort.c index d22f1f051d..93ff89499d 100644 --- a/src/tsort.c +++ b/src/tsort.c @@ -280,7 +280,7 @@ record_relation (struct item *j, struct item *k) } static bool -count_items (struct item *unused ATTRIBUTE_UNUSED) +count_items (struct item *unused _GL_UNUSED) { n_strings++; return false;