git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 1/2] commit-slabs: move MAYBE_UNUSED out

From
Jeff King <peff@peff.net>
Date
Oct 23, 2018, 22:00 UTC
Message-ID
<20181023220019.GA31613@sigill.intra.peff.net>
In-Reply-To
<20181023215020.18550-2-carenas@gmail.com>
On Tue, Oct 23, 2018 at 02:50:19PM -0700, Carlo Marcelo Arenas Belón wrote:
> after 36da893114 ("config.mak.dev: enable -Wunused-function", 2018-10-18)
> it is expected to be used to prevent -Wunused-function warnings for code
> that was macro generated
Makes sense.
Show 10 quoted lines
> diff --git a/commit-slab-impl.h b/commit-slab-impl.h
> index ac1e6d409a..5c0eb91a5d 100644
> --- a/commit-slab-impl.h
> +++ b/commit-slab-impl.h
> @@ -1,10 +1,10 @@
>  #ifndef COMMIT_SLAB_IMPL_H
>  #define COMMIT_SLAB_IMPL_H
>  
> -#define MAYBE_UNUSED __attribute__((__unused__))
> +#include "git-compat-util.h"

We shouldn't need to include git-compat-util.h, as the C files would already do so, via this rule in CodingGuidelines:

   - The first #include in C files, except in platform specific compat/
   implementations, must be either "git-compat-util.h", "cache.h" or
   "builtin.h".  You do not have to include more than one of these.
(and if there is a case that does not, we should fix that).
>  #define implement_static_commit_slab(slabname, elemtype) \
> -	implement_commit_slab(slabname, elemtype, static MAYBE_UNUSED)
> +	implement_commit_slab(slabname, elemtype, MAYBE_UNUSED static)
Is this hunk necessary?
Show 11 quoted lines
> diff --git a/git-compat-util.h b/git-compat-util.h
> index 9a64998b24..e4d3967a23 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -408,6 +408,8 @@ static inline char *git_find_last_dir_sep(const char *path)
>  #define LAST_ARG_MUST_BE_NULL
>  #endif
>  
> +#define MAYBE_UNUSED __attribute__((__unused__))
> +
>  #include "compat/bswap.h"
Looks good.
-Peff
Previous: Carlo Marcelo Arenas BelónNext: Carlo Arenas
Message 5 of 9 in “khash: silence -Wunused-function”
  1. khash: silence -Wunused-functionCarlo Marcelo Arenas Belón, Oct 23, 2018
  2. Duy NguyenOct 23, 2018
  3. 0/2 delta-islands: avoid unused function messagesCarlo Marcelo Arenas Belón, Oct 23, 2018
  4. 1/2 commit-slabs: move MAYBE_UNUSED outCarlo Marcelo Arenas Belón, Oct 23, 2018
  5. Jeff KingOct 23, 2018
  6. Carlo ArenasOct 23, 2018
  7. 2/2 khash: silence -Wunused-function for delta-islandsCarlo Marcelo Arenas Belón, Oct 23, 2018
  8. René ScharfeOct 23, 2018
  9. Carlo ArenasOct 23, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.