public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Thomas Rast <tr@thomasrast•ch>
Cc: Jeff King <peff@peff•net>, git@vger•kernel.org
Subject: Re: [PATCH 2/2] commit-slab: declare functions "static inline"
Date: Mon, 25 Nov 2013 11:36:31 -0800	[thread overview]
Message-ID: <xmqqy54cxohs.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <f4d1ff9f487f797da35faa86c72d11832903a50d.1385405977.git.tr@thomasrast.ch> (Thomas Rast's message of "Mon, 25 Nov 2013 20:02:01 +0100")

Thomas Rast <tr@thomasrast•ch> writes:

> This shuts up compiler warnings about unused functions.

Thanks.

> While there, also remove the redundant second declaration of
> stat_##slabname##realloc.

I think the latter was done very much deliberately to allow the
using code to say:

	define_commit_slab(name, type);

by ending the macro with something that requires a terminating
semicolon.  If you just remove it, doesn't it break the compilation
by forcing the expanded source to define a function

	slabname ## _at(...)
        {
        	...
	};

with a trailing and undesired semicolon?

>
> Signed-off-by: Thomas Rast <tr@thomasrast•ch>
> ---
>  commit-slab.h | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/commit-slab.h b/commit-slab.h
> index d77aaea..d5c353e 100644
> --- a/commit-slab.h
> +++ b/commit-slab.h
> @@ -45,8 +45,8 @@ struct slabname {							\
>  };									\
>  static int stat_ ##slabname## realloc;					\
>  									\
> -static void init_ ##slabname## _with_stride(struct slabname *s,		\
> -					    unsigned stride)		\
> +static inline void init_ ##slabname## _with_stride(struct slabname *s,	\
> +						   unsigned stride)	\
>  {									\
>  	unsigned int elem_size;						\
>  	if (!stride)							\
> @@ -58,12 +58,12 @@ struct slabname {							\
>  	s->slab = NULL;							\
>  }									\
>  									\
> -static void init_ ##slabname(struct slabname *s)			\
> +static inline void init_ ##slabname(struct slabname *s)			\
>  {									\
>  	init_ ##slabname## _with_stride(s, 1);				\
>  }									\
>  									\
> -static void clear_ ##slabname(struct slabname *s)			\
> +static inline void clear_ ##slabname(struct slabname *s)		\
>  {									\
>  	int i;								\
>  	for (i = 0; i < s->slab_count; i++)				\
> @@ -73,8 +73,8 @@ struct slabname {							\
>  	s->slab = NULL;							\
>  }									\
>  									\
> -static elemtype *slabname## _at(struct slabname *s,			\
> -				const struct commit *c)			\
> +static inline elemtype *slabname## _at(struct slabname *s,		\
> +				       const struct commit *c)		\
>  {									\
>  	int nth_slab, nth_slot;						\
>  									\
> @@ -94,8 +94,7 @@ struct slabname {							\
>  		s->slab[nth_slab] = xcalloc(s->slab_size,		\
>  					    sizeof(**s->slab) * s->stride);		\
>  	return &s->slab[nth_slab][nth_slot * s->stride];				\
> -}									\
> -									\
> -static int stat_ ##slabname## realloc
> +}
> +
>  
>  #endif /* COMMIT_SLAB_H */

  reply	other threads:[~2013-11-25 19:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-25 19:01 [PATCH 0/2] commit-slab cleanups Thomas Rast
2013-11-25 19:02 ` [PATCH 1/2] commit-slab: document clear_$slabname() Thomas Rast
2013-11-25 20:24   ` Jonathan Nieder
2013-11-29 19:35     ` Thomas Rast
2013-11-25 20:39   ` Junio C Hamano
2013-11-27 10:39     ` Eric Sunshine
2013-11-25 19:02 ` [PATCH 2/2] commit-slab: declare functions "static inline" Thomas Rast
2013-11-25 19:36   ` Junio C Hamano [this message]
2013-11-25 19:53     ` Thomas Rast
2013-11-25 20:04       ` [PATCH v2] " Thomas Rast
2013-11-25 20:12         ` Jonathan Nieder
2013-11-25 20:15           ` Thomas Rast
2013-11-25 20:35             ` Jonathan Nieder
2013-11-25 20:33           ` Junio C Hamano
2013-11-25 20:23         ` Junio C Hamano
2013-12-01 10:36   ` [PATCH 2/2] " Duy Nguyen
2013-12-01 20:41     ` [PATCH] commit-slab: sizeof() the right type in xrealloc Thomas Rast
2013-12-02 15:35       ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqy54cxohs.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=peff@peff$(echo .)net \
    --cc=tr@thomasrast$(echo .)ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox