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

Re: [PATCH] sequencer: cleanup for gcc 8.2.1 warning

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 25, 2018, 06:22 UTC
Message-ID
<xmqq8t2mk0jo.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<xmqqlg6mk2pd.fsf@gitster-ct.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> I'd have to say that the ability to create an empty file is more
> important in the longer term.  Can't the workaround be done to
> write_file() instead?  I actually do not mind if the solution were
> to introduce a newhelper "write_empty_file()", but the way it is
> written in the code before this patch, i.e.
>
> 	write_file(FILENAME, "")
>
> is so obvious a way to create an empty file, so if we do not have to
> resort to such a hackery to special case an empty file, that would
> be preferrable.
It turns out that we have dealt with this before.

The trick employed by 7d7d6802 ("silence a bunch of format-zero-length warnings", 2014-05-04) is still a caller side workaround, but to do

	-	status_printf_ln(s, GIT_COLOR_NORMAL, "");
	+	status_printf_ln(s, GIT_COLOR_NORMAL, "%s", "");
to the function whose third parameter is printf format.
I do not know if it is a good idea to define a macro
	#define	EMPTY_CONTENTS	"%s", ""

in git-compat-util.h and then replace all the occurrences of "%s", "" in the source code with it. That way, we'd be able to create an empty file with

	write_file(FILENAME, EMPTY_CONTENTS);
and write out an empty line with
	status_printf_ln(s, GIT_COLOR_NORMAL, EMPTY_CONTENTS);

and they would read naturally. But may be it is a bit too cute an idea? I dunno.

	
Previous: Junio C HamanoNext: Carlo Arenas
Message 3 of 7 in “sequencer: cleanup for gcc 8.2.1 warning”
  1. sequencer: cleanup for gcc 8.2.1 warningCarlo Marcelo Arenas Belón, Oct 25, 2018
  2. Junio C HamanoOct 25, 2018
  3. Junio C HamanoOct 25, 2018
  4. Carlo ArenasOct 25, 2018
  5. Junio C HamanoOct 25, 2018
  6. Carlo ArenasOct 25, 2018
  7. sequencer: cleanup for gcc warning in non developer modeCarlo Marcelo Arenas Belón, Oct 25, 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.