[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Avoid one "parameter unused" warnings.

From: Eric Blake
Subject: Re: [PATCH] Avoid one "parameter unused" warnings.
Date: Tue, 2 Jan 2018 15:48:08 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0

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.  */
-get_stat_birthtime_ns (struct stat const *st)
+get_stat_birthtime_ns (struct stat const *st _GL_UNUSED)
   return STAT_TIMESPEC (st, st_birthtim).tv_nsec;
   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.  */
-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;

@@ -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.  */
-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

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]