Re: [PATCH] reftable: make REFTABLE_UNUSED C99 compatible

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

 



On Thu, May 29, 2025 at 09:17:14AM -0700, Junio C Hamano wrote:
> Carlo Marcelo Arenas Belón <carenas@xxxxxxxxx> writes:
> 
> > Since f93b2a0424 (reftable/basics: introduce `REFTABLE_UNUSED`
> > annotation, 2025-02-18), the reftable library was migrated to
> > use an internal version of `UNUSED`, which unconditionally sets
> > a GNU __attribute__ to avoid warnings function parameters that
> > are not being used.
> >
> > Make the definition conditional to prevent breaking the build
> > with non GNU compilers.
> 
> Quite a reasonable reasoning.
> 
> > Reported-by: "Randall S. Becker" <rsbecker@xxxxxxxxxxxxx>
> > Signed-off-by: Carlo Marcelo Arenas Belón <carenas@xxxxxxxxx>
> > ---
> >  reftable/basics.h | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/reftable/basics.h b/reftable/basics.h
> > index d8888c1262..7d22f96261 100644
> > --- a/reftable/basics.h
> > +++ b/reftable/basics.h
> > @@ -16,7 +16,11 @@
> >  #include "system.h"
> >  #include "reftable-basics.h"
> >  
> > +#ifdef __GNUC__
> >  #define REFTABLE_UNUSED __attribute__((__unused__))
> > +#else
> > +#define REFTABLE_UNUSED
> > +#endif
> 
> Corresponding definition we use in the main part of the project
> defined in compat/posix.h looks like this:
> 
>         #if GIT_GNUC_PREREQ(4, 5)
>         #define UNUSED __attribute__((unused)) \
>                 __attribute__((deprecated ("parameter declared as UNUSED")))
>         #elif defined(__GNUC__)
>         #define UNUSED __attribute__((unused)) \
>                 __attribute__((deprecated))
>         #else
>         #define UNUSED
>         #endif
> 
> GCC 4.5 or older may no longer be relevant, in which case yours may
> be good enough.

What I don't understand though: we have a `MAYBE_UNUSED` macro that has
the exact same definition in "git-compat-util.h". Why does the macro
cause issues in the reftable library, but not over there?

Patrick




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux