threads / patch / 37927

patchrun-command: use void to declare that functions take no parameters

Subject: [PATCH] run-command: use void to declare that functions take no parameters

## tl;dr

4 messages between Nov 10, 2014 and Nov 11, 2014. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

René Scharfe· Nov 10, 2014, 21:17 UTC · lore

Explicitly declare that git_atexit_dispatch() and git_atexit_clear() take no parameters instead of leaving their parameter list empty and thus unspecified.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 run-command.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Show changes to run-command.c +2 −2
diff --git a/run-command.c b/run-command.c
index 79a0a76..a476999 100644
--- a/run-command.c
+++ b/run-command.c
@@ -636,7 +636,7 @@ static struct {
 
 static int git_atexit_installed;
 
-static void git_atexit_dispatch()
+static void git_atexit_dispatch(void)
 {
 	size_t i;
 
@@ -644,7 +644,7 @@ static void git_atexit_dispatch()
 		git_atexit_hdlrs.handlers[i-1]();
 }
 
-static void git_atexit_clear()
+static void git_atexit_clear(void)
 {
 	free(git_atexit_hdlrs.handlers);
 	memset(&git_atexit_hdlrs, 0, sizeof(git_atexit_hdlrs));
-- 
2.1.3
Junio C Hamano· Nov 10, 2014, 22:43 UTC · re: René Scharfe · lore

Re: [PATCH] run-command: use void to declare that functions take no parameters

René Scharfe <l.s.r@web.de> writes:
Show 6 quoted lines
> Explicitly declare that git_atexit_dispatch() and git_atexit_clear()
> take no parameters instead of leaving their parameter list empty and
> thus unspecified.
>
> Signed-off-by: Rene Scharfe <l.s.r@web.de>
> ---
Thanks.

I was kind of surprised after running a git blame to find that this is a recent thing, and the same patch looked quite substandard with numerious style violations, and I somehow managed to let them slip in X-<. Perhaps I was having a bad day or something...

Show 25 quoted lines
>  run-command.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/run-command.c b/run-command.c
> index 79a0a76..a476999 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -636,7 +636,7 @@ static struct {
>  
>  static int git_atexit_installed;
>  
> -static void git_atexit_dispatch()
> +static void git_atexit_dispatch(void)
>  {
>  	size_t i;
>  
> @@ -644,7 +644,7 @@ static void git_atexit_dispatch()
>  		git_atexit_hdlrs.handlers[i-1]();
>  }
>  
> -static void git_atexit_clear()
> +static void git_atexit_clear(void)
>  {
>  	free(git_atexit_hdlrs.handlers);
>  	memset(&git_atexit_hdlrs, 0, sizeof(git_atexit_hdlrs));
Jeff King· Nov 11, 2014, 02:54 UTC · re: Junio C Hamano · lore

Re: [PATCH] run-command: use void to declare that functions take no parameters

On Mon, Nov 10, 2014 at 02:43:10PM -0800, Junio C Hamano wrote:
Show 9 quoted lines
> > Explicitly declare that git_atexit_dispatch() and git_atexit_clear()
> > take no parameters instead of leaving their parameter list empty and
> > thus unspecified.
> [...]
> 
> I was kind of surprised after running a git blame to find that this
> is a recent thing, and the same patch looked quite substandard with
> numerious style violations, and I somehow managed to let them slip
> in X-<.  Perhaps I was having a bad day or something...

I had always just assumed that -Wstrict-prototypes was part of -Wall, but it is not (nor even part of -Wextra!). Maybe it is time to add it to your integration-build flags. :)

Looks like we also need this on top of hv/submodule-config (still in pu, so squashing is probably best):

Show changes to submodule-config.h +1 −2
diff --git a/submodule-config.h b/submodule-config.h
index 58afc83..9061e4e 100644
--- a/submodule-config.h
+++ b/submodule-config.h
@@ -24,6 +24,6 @@ const struct submodule *submodule_from_name(const unsigned char *commit_sha1,
 		const char *name);
 const struct submodule *submodule_from_path(const unsigned char *commit_sha1,
 		const char *path);
-void submodule_free();
+void submodule_free(void);
 
 #endif /* SUBMODULE_CONFIG_H */

-Peff
Junio C Hamano· Nov 11, 2014, 17:32 UTC · re: Jeff King · lore

Re: [PATCH] run-command: use void to declare that functions take no parameters

Jeff King <peff@peff.net> writes:
> I had always just assumed that -Wstrict-prototypes was part of -Wall,
> but it is not (nor even part of -Wextra!). Maybe it is time to add it to
> your integration-build flags. :)

Yup, I had -Wold-style-definition but not -Wstrict-prototypes in the mix. Thanks for spotting.

Show 18 quoted lines
>
> Looks like we also need this on top of hv/submodule-config (still in pu,
> so squashing is probably best):
>
> diff --git a/submodule-config.h b/submodule-config.h
> index 58afc83..9061e4e 100644
> --- a/submodule-config.h
> +++ b/submodule-config.h
> @@ -24,6 +24,6 @@ const struct submodule *submodule_from_name(const unsigned char *commit_sha1,
>  		const char *name);
>  const struct submodule *submodule_from_path(const unsigned char *commit_sha1,
>  		const char *path);
> -void submodule_free();
> +void submodule_free(void);
>  
>  #endif /* SUBMODULE_CONFIG_H */
>
> -Peff

← back to recent threads