]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: cleanup up various uses of __attribute__
authorPádraig Brady <P@draigBrady.com>
Tue, 19 Feb 2013 10:58:51 +0000 (10:58 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 20 Feb 2013 04:04:25 +0000 (04:04 +0000)
* 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.

13 files changed:
cfg.mk
src/chown-core.c
src/chroot.c
src/copy.c
src/extent-scan.c
src/factor.c
src/ls.c
src/od.c
src/stat.c
src/stty.c
src/system.h
src/tac.c
src/tsort.c

diff --git a/cfg.mk b/cfg.mk
index c9952d2c0c4a254514eca2c7da13eb83dfa42af2..6fa7b1f72848977f7929f2a465f7730f1b32b857 100644 (file)
--- 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
index 3a3044e04f8e4f83320e3b025295c668496978c6..a5a2b4761ef7e7300c5bd39a3c8a99f36ed17048 100644 (file)
@@ -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.  */
index 1c1a9769502eec874f209d05989ccc337c291616..b77a8bf667b0ef5fac0b50e34a57d4f9b6e7a4b5 100644 (file)
@@ -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;
 }
index 3f2cc2b0c2654625bc88b53a5bf4e36c07c69bbd..244313ee707b2f53a20827bfde24d414c841d43e 100644 (file)
@@ -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;
 }
index 5d25b9aaba3ab3e0ffb8773a4c6930ac70108bf2..6d3032a7276e47be2278bd1e99bd81845ea1452a 100644 (file)
@@ -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;
index 8f1542a2f47cd6b596289609aebf54684e90e009..257a7ed90e1147a580d4ea8ca13da0b98be3562a 100644 (file)
@@ -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;
index f1ed43bd23191f1450227bfed456f1b7ce19a53a..d9876f842794f075895a74dfc5bddf716c6c408e 100644 (file)
--- 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;
index ffccd7410ad4f2d2344c8081d1011f9df905837e..e7d881b28ec2d0ed33e3061aca6a132c3d58c46a 100644 (file)
--- 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)
 {
 }
 
index dd210d181ca9d1cb18bb208b1ec7cbf91bb48de0..232669811ff3f01d49aa426c29e628c00e3f9519 100644 (file)
@@ -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);
index ee891a593354fde0494fb2a20728cce79dc74f12..e518839d58e08bf1e762563a0304a9c106afd53b 100644 (file)
@@ -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;
index 1677999ef74f8ae29134700919e9e01c21bad101..0605a2f2e57ce0703adc44bedcf1c3dcbae7f342 100644 (file)
@@ -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)
index c6a8cf69581488c18c93c4990472e77ff2ae8cf5..5bf40a7e8524bbfcda64ae729580a2e609ad72d9 100644 (file)
--- 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);
 }
index d22f1f051dbf69c46a6fa2383e4600a3afe937db..93ff89499dff5dcb331e0de311fc2dd319dc125d 100644 (file)
@@ -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;