On 01/01/2018 03:53 AM, Paul Eggert wrote: > Thanks, but -Wunused-parameter issues so many false alarms that I think > I'd rather just ask people to compile with -Wno-unused-parameter. That's > what coreutils does, and Emacs, and so forth. > > By the way, this thread duplicates one of a couple of days ago, starting > here: > > http://lists.gnu.org/archive/html/bug-gnulib/2017-12/msg00077.html > > Is there some new project using Gnulib that is causing these new > messages? If so, perhaps I should propose a patch to it to pacify GCC > without having to pollute the code with void no-op casts.
Note that this patch is copying the style that is already present in get_stat_birthtime_ns(), so on that grounds, I'd argue that we WANT the patch for consistency. But why not use _GL_UNUSED instead of cast-to-void (after all, gcc does NOT warn if you mark something with _GL_UNUSED but then actually use it; precisely because of situations where the use is conditional based on #if)? As in: diff --git i/lib/stat-time.h w/lib/stat-time.h index 5f8bf4e12..104f53766 100644 --- i/lib/stat-time.h +++ w/lib/stat-time.h @@ -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) -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature