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

Re: [PATCH] Fix some sparse warnings

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 21, 2013, 20:58 UTC
Message-ID
<7vmwpfsk8d.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20130721173936.GA10647@elie.Belkin>
Jonathan Nieder <jrnieder@gmail.com> writes:
Show 11 quoted lines
> How about something like the following?
>
> diff --git i/cache.h w/cache.h
> index f2915509..ba028b75 100644
> --- i/cache.h
> +++ w/cache.h
> @@ -1124,6 +1124,7 @@ struct object_info {
>  		} packed;
>  	} u;
>  };
> +#define OBJECT_INFO_INIT { NULL, NULL, OI_CACHED, { { NULL, 0, 0 } } }
There are quite a many hits from
	$ git grep '= { *NULL *};'

only some of which are "char *var[] = { NULL }", which is perfectly fine, but others are to initialise "struct foo" (or "foo_t" which is typedef'ed) that share the same "writing NULL means the initialiser knows the order of the fields".

I doubt if the above #define is a maintainable solution, and worse yet, thinking about the fact that such a macro is necessary only for a structure whose first field happens to be of a pointer type, it strongly suggests me that it is not conceptually the right thing to do.

Can't we have sparse fixed (or skip this specific warning) instead?
Previous: Jonathan Nieder
Message 5 of 5 in “Fix some sparse warnings”
  1. Fix some sparse warningsRamsay Jones, Jul 18, 2013
  2. Jeff KingJul 18, 2013
  3. Ramsay JonesJul 20, 2013
  4. Jonathan NiederJul 21, 2013
  5. Junio C HamanoJul 21, 2013

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.