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

Re: [PATCH 2/2] Fix sparse warnings

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Mar 21, 2011, 10:10 UTC
Message-ID
<4D872420.8080501@viscovery.net>
In-Reply-To
<1300700704-22674-2-git-send-email-bebarino@gmail.com>
Am 3/21/2011 10:45, schrieb Stephen Boyd:
Show 10 quoted lines
> diff --git a/daemon.c b/daemon.c
> index 347fd0c..4c8346d 100644
> --- a/daemon.c
> +++ b/daemon.c
> @@ -660,7 +660,7 @@ static void check_dead_children(void)
>  static char **cld_argv;
>  static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
>  {
> -	struct child_process cld = { 0 };
> +	struct child_process cld = { NULL };
IMO this change is not good.

The purpose of { 0} is not to initialize (only) the first member, but rather to serve as a visual marker that says "We want the complete struct zero-initialized".

Show 10 quoted lines
> diff --git a/fast-import.c b/fast-import.c
> index d9f9a3f..65d65bf 100644
> --- a/fast-import.c
> +++ b/fast-import.c
> @@ -2939,7 +2939,7 @@ static void parse_ls(struct branch *b)
>  {
>  	const char *p;
>  	struct tree_entry *root = NULL;
> -	struct tree_entry leaf = {0};
> +	struct tree_entry leaf = {NULL};
Same here.
Show 10 quoted lines
> diff --git a/imap-send.c b/imap-send.c
> index 71506a8..9adf4b9 100644
> --- a/imap-send.c
> +++ b/imap-send.c
> @@ -1069,7 +1069,7 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)
>  
>  	if (srvc->tunnel) {
>  		const char *argv[] = { srvc->tunnel, NULL };
> -		struct child_process tunnel = {0};
> +		struct child_process tunnel = {NULL};
And here.
Show 10 quoted lines
> diff --git a/transport.c b/transport.c
> index 0078660..f1c0781 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -192,7 +192,7 @@ static const char *rsync_url(const char *url)
>  static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)
>  {
>  	struct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT;
> -	struct ref dummy = {0}, *tail = &dummy;
> +	struct ref dummy = {NULL}, *tail = &dummy;
And here.
-- Hannes
Previous: Stephen BoydNext: Stephen Boyd
Message 3 of 13 in “Makefile: Cover more files with make check”
  1. 1/2 Makefile: Cover more files with make checkStephen Boyd, Mar 21, 2011
  2. 2/2 Fix sparse warningsStephen Boyd, Mar 21, 2011
  3. Johannes SixtMar 21, 2011
  4. Stephen BoydMar 21, 2011
  5. Junio C HamanoMar 21, 2011
  6. Junio C HamanoMar 21, 2011
  7. 2/2 Fix sparse warningsStephen Boyd, Mar 21, 2011
  8. Junio C HamanoMar 21, 2011
  9. Junio C HamanoMar 21, 2011
  10. Stephen BoydMar 21, 2011
  11. 2/2 Fix sparse warningsStephen Boyd, Mar 22, 2011
  12. Junio C HamanoMar 22, 2011
  13. Junio C HamanoMar 21, 2011

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.