浏览代码

maint: port better to non-GCC compilers

This can be helpful in porting to compilers like Oracle Developer
Studio that support some but not all GCC attributes.
* lib/wordsplit.c (FALLTHROUGH): Remove; now done by attribute.h.
* lib/wordsplit.h (__WORDSPLIT_ATTRIBUTE_FORMAT): Remove;
all uses replaced by ATTRIBUTE_FORMAT.
* lib/wordsplit.h, src/buffer.c, src/common.h, src/compare.c:
* src/sparse.c, src/system.c, src/xheader.c:
Prefer ATTRIBUTE_FORMAT, MAYBE_UNUSED, _Noreturn, etc. to
__attribute__.
Paul Eggert 4 年之前
父节点
当前提交
f4e2411bf5
共有 8 个文件被更改,包括 77 次插入95 次删除
  1. 1 9
      lib/wordsplit.c
  2. 13 18
      lib/wordsplit.h
  3. 1 1
      src/buffer.c
  4. 6 7
      src/common.h
  5. 1 2
      src/compare.c
  6. 6 6
      src/sparse.c
  7. 1 3
      src/system.c
  8. 48 49
      src/xheader.c

+ 1 - 9
lib/wordsplit.c

@@ -36,14 +36,6 @@
 #define _(msgid) gettext (msgid)
 #define N_(msgid) msgid
 
-#ifndef FALLTHROUGH
-# if __GNUC__ < 7
-#  define FALLTHROUGH ((void) 0)
-# else
-#  define FALLTHROUGH __attribute__ ((__fallthrough__))
-# endif
-#endif
-
 #include <wordsplit.h>
 
 #define ISWS(c) ((c)==' '||(c)=='\t'||(c)=='\n')
@@ -74,7 +66,7 @@ _wsplt_alloc_die (struct wordsplit *wsp)
   abort ();
 }
 
-static void __WORDSPLIT_ATTRIBUTE_FORMAT ((__printf__, 1, 2))
+static void ATTRIBUTE_FORMAT ((__printf__, 1, 2))
 _wsplt_error (const char *fmt, ...)
 {
   va_list ap;

+ 13 - 18
lib/wordsplit.h

@@ -18,12 +18,7 @@
 #define __WORDSPLIT_H
 
 #include <stddef.h>
-
-#if 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
-# define __WORDSPLIT_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
-#else
-# define __WORDSPLIT_ATTRIBUTE_FORMAT(spec) /* empty */
-#endif
+#include <attribute.h>
 
 typedef struct wordsplit wordsplit_t;
 
@@ -36,16 +31,16 @@ typedef struct wordsplit wordsplit_t;
    must be set (or unset, if starting with !) in ws_flags (if starting with
    WRDSF_) or ws_options (if starting with WRDSO_) to initialize or use the
    given member.
-   
+
    If not redefined explicitly, most of them are set to some reasonable
    default value upon entry to wordsplit(). */
-struct wordsplit            
+struct wordsplit
 {
   size_t ws_wordc;          /* [Output] Number of words in ws_wordv. */
   char **ws_wordv;          /* [Output] Array of parsed out words. */
   size_t ws_offs;           /* [Input] (WRDSF_DOOFFS) Number of initial
 			       elements in ws_wordv to fill with NULLs. */
-  size_t ws_wordn;          /* Number of elements ws_wordv can accomodate. */ 
+  size_t ws_wordn;          /* Number of elements ws_wordv can accomodate. */
   unsigned ws_flags;        /* [Input] Flags passed to wordsplit. */
   unsigned ws_options;      /* [Input] (WRDSF_OPTIONS)
 			       Additional options. */
@@ -62,11 +57,11 @@ struct wordsplit
                             /* [Input] (WRDSF_ALLOC_DIE) Function called when
 			       out of memory.  Must not return. */
   void (*ws_error) (const char *, ...)
-                   __attribute__ ((__format__ (__printf__, 1, 2)));
+		ATTRIBUTE_FORMAT ((printf, 1, 2));
                             /* [Input] (WRDSF_ERROR) Function used for error
 			       reporting */
   void (*ws_debug) (const char *, ...)
-                   __attribute__ ((__format__ (__printf__, 1, 2)));
+		ATTRIBUTE_FORMAT ((printf, 1, 2));
                             /* [Input] (WRDSF_DEBUG) Function used for debug
 			       output. */
   const char **ws_env;      /* [Input] (WRDSF_ENV, !WRDSF_NOVAR) Array of
@@ -75,7 +70,7 @@ struct wordsplit
   char **ws_envbuf;
   size_t ws_envidx;
   size_t ws_envsiz;
-  
+
   int (*ws_getvar) (char **ret, const char *var, size_t len, void *clos);
                             /* [Input] (WRDSF_GETVAR, !WRDSF_NOVAR) Looks up
 			       the name VAR (LEN bytes long) in the table of
@@ -100,8 +95,8 @@ struct wordsplit
 
 			       See ws_getvar for a discussion of possible
 			       return values. */
-	
-  const char *ws_input;     /* Input string (the S argument to wordsplit. */  
+
+  const char *ws_input;     /* Input string (the S argument to wordsplit. */
   size_t ws_len;            /* Length of ws_input. */
   size_t ws_endp;           /* Points past the last processed byte in
 			       ws_input. */
@@ -221,9 +216,9 @@ struct wordsplit
 /* Handle hex escapes in quoted strings */
 #define WRDSO_XESC_QUOTE      0x00000400
 
-#define WRDSO_BSKEEP          WRDSO_BSKEEP_WORD     
-#define WRDSO_OESC            WRDSO_OESC_WORD       
-#define WRDSO_XESC            WRDSO_XESC_WORD       
+#define WRDSO_BSKEEP          WRDSO_BSKEEP_WORD
+#define WRDSO_OESC            WRDSO_OESC_WORD
+#define WRDSO_XESC            WRDSO_XESC_WORD
 
 /* Indices into ws_escape */
 #define WRDSX_WORD  0
@@ -254,7 +249,7 @@ void wordsplit_free_envbuf (wordsplit_t *ws);
 int wordsplit_get_words (wordsplit_t *ws, size_t *wordc, char ***wordv);
 
 static inline void wordsplit_getwords (wordsplit_t *ws, size_t *wordc, char ***wordv)
-  __attribute__ ((deprecated));
+  DEPRECATED;
 
 static inline void
 wordsplit_getwords (wordsplit_t *ws, size_t *wordc, char ***wordv)

+ 1 - 1
src/buffer.c

@@ -1850,7 +1850,7 @@ simple_flush_read (void)
 
 /* Simple flush write (no multi-volume or label extensions) */
 static void
-simple_flush_write (size_t level __attribute__((unused)))
+simple_flush_write (size_t level MAYBE_UNUSED)
 {
   ssize_t status;
 

+ 6 - 7
src/common.h

@@ -464,7 +464,7 @@ void reset_eof (void);
 void set_next_block_after (union block *block);
 void clear_read_error_count (void);
 void xclose (int fd);
-void archive_write_error (ssize_t status) __attribute__ ((noreturn));
+_Noreturn void archive_write_error (ssize_t status);
 void archive_read_error (void);
 off_t seek_archive (off_t size);
 void set_start_time (void);
@@ -727,9 +727,8 @@ void stat_diag (char const *name);
 void file_removed_diag (const char *name, bool top_level,
 			void (*diagfn) (char const *name));
 void write_error_details (char const *name, size_t status, size_t size);
-void write_fatal (char const *name) __attribute__ ((noreturn));
-void write_fatal_details (char const *name, ssize_t status, size_t size)
-     __attribute__ ((noreturn));
+_Noreturn void write_fatal (char const *name);
+_Noreturn void write_fatal_details (char const *name, ssize_t status, size_t size);
 
 pid_t xfork (void);
 void xpipe (int fd[2]);
@@ -797,14 +796,14 @@ bool contains_dot_dot (char const *name);
 
 /* Module tar.c.  */
 
-void usage (int);
+_Noreturn void usage (int);
 
 int confirm (const char *message_action, const char *name);
 
 void tar_stat_init (struct tar_stat_info *st);
 bool tar_stat_close (struct tar_stat_info *st);
 void tar_stat_destroy (struct tar_stat_info *st);
-void usage (int) __attribute__ ((noreturn));
+_Noreturn void usage (int);
 int tar_timespec_cmp (struct timespec a, struct timespec b);
 const char *archive_format_string (enum archive_format fmt);
 const char *subcommand_string (enum subcommand c);
@@ -913,7 +912,7 @@ void sys_exec_checkpoint_script (const char *script_name,
 
 /* Module compare.c */
 void report_difference (struct tar_stat_info *st, const char *message, ...)
-  __attribute__ ((format (printf, 2, 3)));
+  ATTRIBUTE_FORMAT ((printf, 2, 3));
 
 /* Module sparse.c */
 bool sparse_member_p (struct tar_stat_info *st);

+ 1 - 2
src/compare.c

@@ -73,8 +73,7 @@ report_difference (struct tar_stat_info *st, const char *fmt, ...)
 
 /* Take a buffer returned by read_and_process and do nothing with it.  */
 static int
-process_noop (size_t size __attribute__ ((unused)),
-	      char *data __attribute__ ((unused)))
+process_noop (size_t size MAYBE_UNUSED, char *data MAYBE_UNUSED)
 {
   return 1;
 }

+ 6 - 6
src/sparse.c

@@ -439,7 +439,7 @@ sparse_dump_region (struct tar_sparse_file *file, size_t i)
 	      - (file->stat_info->sparse_map[i].offset
 		 + file->stat_info->sparse_map[i].numbytes
 		 - bytes_left);
-	  
+
 	  WARNOPT (WARN_FILE_SHRANK,
 		   (0, 0,
 		    ngettext ("%s: File shrank by %s byte; padding with zeros",
@@ -627,7 +627,7 @@ check_sparse_region (struct tar_sparse_file *file, off_t beg, off_t end)
 	  report_difference (file->stat_info, _("Size differs"));
 	  return false;
 	}
-      
+
       if (!zero_block_p (diff_buffer, bytes_read))
 	{
 	  char begbuf[INT_BUFSIZE_BOUND (off_t)];
@@ -666,7 +666,7 @@ check_data_region (struct tar_sparse_file *file, size_t i)
 	  return false;
 	}
       set_next_block_after (blk);
-      file->dumped_size += BLOCKSIZE;      
+      file->dumped_size += BLOCKSIZE;
       bytes_read = safe_read (file->fd, diff_buffer, rdsize);
       if (bytes_read == SAFE_READ_ERROR)
 	{
@@ -754,7 +754,7 @@ enum oldgnu_add_status
   };
 
 static bool
-oldgnu_sparse_member_p (struct tar_sparse_file *file __attribute__ ((unused)))
+oldgnu_sparse_member_p (struct tar_sparse_file *file MAYBE_UNUSED)
 {
   return current_header->header.typeflag == GNUTYPE_SPARSE;
 }
@@ -898,7 +898,7 @@ static struct tar_sparse_optab const oldgnu_optab = {
 /* Star */
 
 static bool
-star_sparse_member_p (struct tar_sparse_file *file __attribute__ ((unused)))
+star_sparse_member_p (struct tar_sparse_file *file MAYBE_UNUSED)
 {
   return current_header->header.typeflag == GNUTYPE_SPARSE;
 }
@@ -1250,7 +1250,7 @@ pax_decode_header (struct tar_sparse_file *file)
       char *p;
       size_t i;
       off_t start;
-      
+
 #define COPY_BUF(b,buf,src) do                                     \
  {                                                                 \
    char *endp = b->buffer + BLOCKSIZE;                             \

+ 1 - 3
src/system.c

@@ -298,10 +298,8 @@ xdup2 (int from, int into)
     }
 }
 
-static void wait_for_grandchild (pid_t pid) __attribute__ ((__noreturn__));
-
 /* Propagate any failure of the grandchild back to the parent.  */
-static void
+static _Noreturn void
 wait_for_grandchild (pid_t pid)
 {
   int wait_status;

+ 48 - 49
src/xheader.c

@@ -29,7 +29,6 @@
 static void xheader_init (struct xheader *xhdr);
 static bool xheader_protected_pattern_p (char const *pattern);
 static bool xheader_protected_keyword_p (char const *keyword);
-static void xheader_set_single_keyword (char *) __attribute__ ((noreturn));
 
 /* Used by xheader_finish() */
 static void code_string (char const *string, char const *keyword,
@@ -158,7 +157,7 @@ xheader_list_destroy (struct keyword_list **root)
     }
 }
 
-static void
+static _Noreturn void
 xheader_set_single_keyword (char *kw)
 {
   USAGE_ERROR ((0, 0, _("Keyword %s is unknown or not yet implemented"), kw));
@@ -186,7 +185,7 @@ xheader_set_keyword_equal (char *kw, char *eq)
 
   if (eq == kw)
     USAGE_ERROR ((0, 0, _("Malformed pax option: %s"), quote (kw)));
-    
+
   if (eq[-1] == ':')
     {
       p--;
@@ -306,7 +305,7 @@ xheader_format_name (struct tar_stat_info *st, const char *fmt, size_t n)
 	      nptr = umaxtostr (n, nbuf);
 	      len += nbuf + sizeof nbuf - 1 - nptr;
 	      break;
-	      
+
 	    default:
 	      len += 2;
 	    }
@@ -804,7 +803,7 @@ xheader_decode (struct tar_stat_info *st)
 
 static void
 decg (void *data, char const *keyword, char const *value,
-      size_t size __attribute__((unused)))
+      size_t size MAYBE_UNUSED)
 {
   struct keyword_list **kwl = data;
   struct xhdr_tab const *tab = locate_handler (keyword);
@@ -1196,24 +1195,24 @@ decode_num (uintmax_t *num, char const *arg, uintmax_t maxval,
 }
 
 static void
-dummy_coder (struct tar_stat_info const *st __attribute__ ((unused)),
-	     char const *keyword __attribute__ ((unused)),
-	     struct xheader *xhdr __attribute__ ((unused)),
-	     void const *data __attribute__ ((unused)))
+dummy_coder (struct tar_stat_info const *st MAYBE_UNUSED,
+	     char const *keyword MAYBE_UNUSED,
+	     struct xheader *xhdr MAYBE_UNUSED,
+	     void const *data MAYBE_UNUSED)
 {
 }
 
 static void
-dummy_decoder (struct tar_stat_info *st __attribute__ ((unused)),
-	       char const *keyword __attribute__ ((unused)),
-	       char const *arg __attribute__ ((unused)),
-	       size_t size __attribute__((unused)))
+dummy_decoder (struct tar_stat_info *st MAYBE_UNUSED,
+	       char const *keyword MAYBE_UNUSED,
+	       char const *arg MAYBE_UNUSED,
+	       size_t size MAYBE_UNUSED)
 {
 }
 
 static void
 atime_coder (struct tar_stat_info const *st, char const *keyword,
-	     struct xheader *xhdr, void const *data __attribute__ ((unused)))
+	     struct xheader *xhdr, void const *data MAYBE_UNUSED)
 {
   code_time (st->atime, keyword, xhdr);
 }
@@ -1222,7 +1221,7 @@ static void
 atime_decoder (struct tar_stat_info *st,
 	       char const *keyword,
 	       char const *arg,
-	       size_t size __attribute__((unused)))
+	       size_t size MAYBE_UNUSED)
 {
   struct timespec ts;
   if (decode_time (&ts, arg, keyword))
@@ -1231,7 +1230,7 @@ atime_decoder (struct tar_stat_info *st,
 
 static void
 gid_coder (struct tar_stat_info const *st, char const *keyword,
-	   struct xheader *xhdr, void const *data __attribute__ ((unused)))
+	   struct xheader *xhdr, void const *data MAYBE_UNUSED)
 {
   code_signed_num (st->stat.st_gid, keyword,
 		   TYPE_MINIMUM (gid_t), TYPE_MAXIMUM (gid_t), xhdr);
@@ -1241,7 +1240,7 @@ static void
 gid_decoder (struct tar_stat_info *st,
 	     char const *keyword,
 	     char const *arg,
-	     size_t size __attribute__((unused)))
+	     size_t size MAYBE_UNUSED)
 {
   intmax_t u;
   if (decode_signed_num (&u, arg, TYPE_MINIMUM (gid_t),
@@ -1251,39 +1250,39 @@ gid_decoder (struct tar_stat_info *st,
 
 static void
 gname_coder (struct tar_stat_info const *st, char const *keyword,
-	     struct xheader *xhdr, void const *data __attribute__ ((unused)))
+	     struct xheader *xhdr, void const *data MAYBE_UNUSED)
 {
   code_string (st->gname, keyword, xhdr);
 }
 
 static void
 gname_decoder (struct tar_stat_info *st,
-	       char const *keyword __attribute__((unused)),
+	       char const *keyword MAYBE_UNUSED,
 	       char const *arg,
-	       size_t size __attribute__((unused)))
+	       size_t size MAYBE_UNUSED)
 {
   decode_string (&st->gname, arg);
 }
 
 static void
 linkpath_coder (struct tar_stat_info const *st, char const *keyword,
-		struct xheader *xhdr, void const *data __attribute__ ((unused)))
+		struct xheader *xhdr, void const *data MAYBE_UNUSED)
 {
   code_string (st->link_name, keyword, xhdr);
 }
 
 static void
 linkpath_decoder (struct tar_stat_info *st,
-		  char const *keyword __attribute__((unused)),
+		  char const *keyword MAYBE_UNUSED,
 		  char const *arg,
-		  size_t size __attribute__((unused)))
+		  size_t size MAYBE_UNUSED)
 {
   decode_string (&st->link_name, arg);
 }
 
 static void
 ctime_coder (struct tar_stat_info const *st, char const *keyword,
-	     struct xheader *xhdr, void const *data __attribute__ ((unused)))
+	     struct xheader *xhdr, void const *data MAYBE_UNUSED)
 {
   code_time (st->ctime, keyword, xhdr);
 }
@@ -1292,7 +1291,7 @@ static void
 ctime_decoder (struct tar_stat_info *st,
 	       char const *keyword,
 	       char const *arg,
-	       size_t size __attribute__((unused)))
+	       size_t size MAYBE_UNUSED)
 {
   struct timespec ts;
   if (decode_time (&ts, arg, keyword))
@@ -1311,7 +1310,7 @@ static void
 mtime_decoder (struct tar_stat_info *st,
 	       char const *keyword,
 	       char const *arg,
-	       size_t size __attribute__((unused)))
+	       size_t size MAYBE_UNUSED)
 {
   struct timespec ts;
   if (decode_time (&ts, arg, keyword))
@@ -1320,7 +1319,7 @@ mtime_decoder (struct tar_stat_info *st,
 
 static void
 path_coder (struct tar_stat_info const *st, char const *keyword,
-	    struct xheader *xhdr, void const *data __attribute__ ((unused)))
+	    struct xheader *xhdr, void const *data MAYBE_UNUSED)
 {
   code_string (st->file_name, keyword, xhdr);
 }
@@ -1336,9 +1335,9 @@ raw_path_decoder (struct tar_stat_info *st, char const *arg)
 
 static void
 path_decoder (struct tar_stat_info *st,
-	      char const *keyword __attribute__((unused)),
+	      char const *keyword MAYBE_UNUSED,
 	      char const *arg,
-	      size_t size __attribute__((unused)))
+	      size_t size MAYBE_UNUSED)
 {
   if (! st->sparse_name_done)
     raw_path_decoder (st, arg);
@@ -1346,9 +1345,9 @@ path_decoder (struct tar_stat_info *st,
 
 static void
 sparse_path_decoder (struct tar_stat_info *st,
-                     char const *keyword __attribute__((unused)),
+                     char const *keyword MAYBE_UNUSED,
                      char const *arg,
-                     size_t size __attribute__((unused)))
+                     size_t size MAYBE_UNUSED)
 {
   st->sparse_name_done = true;
   raw_path_decoder (st, arg);
@@ -1356,7 +1355,7 @@ sparse_path_decoder (struct tar_stat_info *st,
 
 static void
 size_coder (struct tar_stat_info const *st, char const *keyword,
-	    struct xheader *xhdr, void const *data __attribute__ ((unused)))
+	    struct xheader *xhdr, void const *data MAYBE_UNUSED)
 {
   code_num (st->stat.st_size, keyword, xhdr);
 }
@@ -1365,7 +1364,7 @@ static void
 size_decoder (struct tar_stat_info *st,
 	      char const *keyword,
 	      char const *arg,
-	      size_t size __attribute__((unused)))
+	      size_t size MAYBE_UNUSED)
 {
   uintmax_t u;
   if (decode_num (&u, arg, TYPE_MAXIMUM (off_t), keyword))
@@ -1374,7 +1373,7 @@ size_decoder (struct tar_stat_info *st,
 
 static void
 uid_coder (struct tar_stat_info const *st, char const *keyword,
-	   struct xheader *xhdr, void const *data __attribute__ ((unused)))
+	   struct xheader *xhdr, void const *data MAYBE_UNUSED)
 {
   code_signed_num (st->stat.st_uid, keyword,
 		   TYPE_MINIMUM (uid_t), TYPE_MAXIMUM (uid_t), xhdr);
@@ -1384,7 +1383,7 @@ static void
 uid_decoder (struct tar_stat_info *st,
 	     char const *keyword,
 	     char const *arg,
-	     size_t size __attribute__((unused)))
+	     size_t size MAYBE_UNUSED)
 {
   intmax_t u;
   if (decode_signed_num (&u, arg, TYPE_MINIMUM (uid_t),
@@ -1394,16 +1393,16 @@ uid_decoder (struct tar_stat_info *st,
 
 static void
 uname_coder (struct tar_stat_info const *st, char const *keyword,
-	     struct xheader *xhdr, void const *data __attribute__ ((unused)))
+	     struct xheader *xhdr, void const *data MAYBE_UNUSED)
 {
   code_string (st->uname, keyword, xhdr);
 }
 
 static void
 uname_decoder (struct tar_stat_info *st,
-	       char const *keyword __attribute__((unused)),
+	       char const *keyword MAYBE_UNUSED,
 	       char const *arg,
-	       size_t size __attribute__((unused)))
+	       size_t size MAYBE_UNUSED)
 {
   decode_string (&st->uname, arg);
 }
@@ -1419,7 +1418,7 @@ static void
 sparse_size_decoder (struct tar_stat_info *st,
 		     char const *keyword,
 		     char const *arg,
-		     size_t size __attribute__((unused)))
+		     size_t size MAYBE_UNUSED)
 {
   uintmax_t u;
   if (decode_num (&u, arg, TYPE_MAXIMUM (off_t), keyword))
@@ -1432,7 +1431,7 @@ sparse_size_decoder (struct tar_stat_info *st,
 static void
 sparse_numblocks_coder (struct tar_stat_info const *st, char const *keyword,
 			struct xheader *xhdr,
-			void const *data __attribute__ ((unused)))
+			void const *data MAYBE_UNUSED)
 {
   code_num (st->sparse_map_avail, keyword, xhdr);
 }
@@ -1441,7 +1440,7 @@ static void
 sparse_numblocks_decoder (struct tar_stat_info *st,
 			  char const *keyword,
 			  char const *arg,
-			  size_t size __attribute__((unused)))
+			  size_t size MAYBE_UNUSED)
 {
   uintmax_t u;
   if (decode_num (&u, arg, SIZE_MAX, keyword))
@@ -1464,7 +1463,7 @@ static void
 sparse_offset_decoder (struct tar_stat_info *st,
 		       char const *keyword,
 		       char const *arg,
-		       size_t size __attribute__((unused)))
+		       size_t size MAYBE_UNUSED)
 {
   uintmax_t u;
   if (decode_num (&u, arg, TYPE_MAXIMUM (off_t), keyword))
@@ -1489,7 +1488,7 @@ static void
 sparse_numbytes_decoder (struct tar_stat_info *st,
 			 char const *keyword,
 			 char const *arg,
-			 size_t size __attribute__((unused)))
+			 size_t size MAYBE_UNUSED)
 {
   uintmax_t u;
   if (decode_num (&u, arg, TYPE_MAXIMUM (off_t), keyword))
@@ -1506,7 +1505,7 @@ static void
 sparse_map_decoder (struct tar_stat_info *st,
 		    char const *keyword,
 		    char const *arg,
-		    size_t size __attribute__((unused)))
+		    size_t size MAYBE_UNUSED)
 {
   int offset = 1;
   struct sp_array e;
@@ -1588,7 +1587,7 @@ dumpdir_coder (struct tar_stat_info const *st, char const *keyword,
 
 static void
 dumpdir_decoder (struct tar_stat_info *st,
-		 char const *keyword __attribute__((unused)),
+		 char const *keyword MAYBE_UNUSED,
 		 char const *arg,
 		 size_t size)
 {
@@ -1605,9 +1604,9 @@ volume_label_coder (struct tar_stat_info const *st, char const *keyword,
 
 static void
 volume_label_decoder (struct tar_stat_info *st,
-		      char const *keyword __attribute__((unused)),
+		      char const *keyword MAYBE_UNUSED,
 		      char const *arg,
-		      size_t size __attribute__((unused)))
+		      size_t size MAYBE_UNUSED)
 {
   decode_string (&volume_label, arg);
 }
@@ -1651,9 +1650,9 @@ volume_offset_decoder (struct tar_stat_info *st,
 
 static void
 volume_filename_decoder (struct tar_stat_info *st,
-			 char const *keyword __attribute__((unused)),
+			 char const *keyword MAYBE_UNUSED,
 			 char const *arg,
-			 size_t size __attribute__((unused)))
+			 size_t size MAYBE_UNUSED)
 {
   decode_string (&continued_file_name, arg);
 }