]> Savannah Git Hosting - gnulib.git/commitdiff
stat-time: silence -Wunused-parameter regression
authorEric Blake <eblake@redhat.com>
Tue, 2 Jan 2018 21:49:27 +0000 (15:49 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 3 Jan 2018 14:53:48 +0000 (08:53 -0600)
Commit 2c5d5587 causes warnings on non-Sun systems when compiled
under -Wunused-parameter; we've previously tweaked code in commit
81eb8486 to avoid such warnings.  Prefer an attribute rather than
a cast to void (the attribute is always okay to apply; gcc
interprets it as 'may be unused', not 'must not be used', precisely
to cater to #if chains where determining whether or not the
parameter is used gets hairy).

* lib/stat-time.h (get_stat_birthtime_ns, get_stat_birthtime):
Prefer attribute over cast-to-void.
(stat_time_normalize): Mark st as potentially unused.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
lib/stat-time.h

index 63be28d5ebf202eed74efa7369c666cffde2cd8b..ea6e730a49f3b1ae0a2c326957662943a0568c4d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-01-02  Eric Blake  <eblake@redhat.com>
+
+       stat-time: silence -Wunused-parameter regression
+       * lib/stat-time.h (get_stat_birthtime_ns, get_stat_birthtime):
+       Prefer attribute over cast-to-void.
+       (stat_time_normalize): Mark st as potentially unused.
+
 2018-01-02  Paul Eggert  <eggert@cs.ucla.edu>
 
        test-framework-sh: avoid netstat
index 5f8bf4e126f7a706df164b7d0056c350492a80c3..104f53766829c5aa3709d9b6bfa7657799813bae 100644 (file)
@@ -102,15 +102,13 @@ get_stat_mtime_ns (struct stat const *st)
 
 /* Return the nanosecond component of *ST's birth time.  */
 _GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
-get_stat_birthtime_ns (struct stat const *st)
+get_stat_birthtime_ns (struct stat const *st _GL_UNUSED)
 {
 # if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC
   return STAT_TIMESPEC (st, st_birthtim).tv_nsec;
 # elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
   return STAT_TIMESPEC_NS (st, st_birthtim);
 # else
-  /* Avoid a "parameter unused" warning.  */
-  (void) st;
   return 0;
 # endif
 }
@@ -160,7 +158,7 @@ get_stat_mtime (struct stat const *st)
 /* Return *ST's birth time, if available; otherwise return a value
    with tv_sec and tv_nsec both equal to -1.  */
 _GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
-get_stat_birthtime (struct stat const *st)
+get_stat_birthtime (struct stat const *st _GL_UNUSED)
 {
   struct timespec t;
 
@@ -184,8 +182,6 @@ get_stat_birthtime (struct stat const *st)
   /* Birth time is not supported.  */
   t.tv_sec = -1;
   t.tv_nsec = -1;
-  /* Avoid a "parameter unused" warning.  */
-  (void) st;
 #endif
 
 #if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
@@ -212,7 +208,7 @@ get_stat_birthtime (struct stat const *st)
    errno to EOVERFLOW if normalization overflowed.  This function
    is intended to be private to this .h file.  */
 _GL_STAT_TIME_INLINE int
-stat_time_normalize (int result, struct stat *st)
+stat_time_normalize (int result, struct stat *st _GL_UNUSED)
 {
 #if defined __sun && defined STAT_TIMESPEC
   if (result == 0)