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

Re: [PATCH 0/2] fix status_printf_ln calls "zero-length format" warnings

From
Jeff King <peff@peff.net>
Date
Mar 10, 2014, 19:51 UTC
Message-ID
<20140310195121.GB24568@sigill.intra.peff.net>
In-Reply-To
<1394479647-22361-1-git-send-email-benoit.pierre@gmail.com>
On Mon, Mar 10, 2014 at 08:27:25PM +0100, Benoit Pierre wrote:
> Those happens with "gcc -Wformat-zero-length". Since passing NULL does not
> generate a warning (as __attribute__((printf())) does not imply nonull), modify
> status_printf/status_printf_ln to allow a NULL format and update calls with an
> empty string.

Most of us who compile with -Wall decided a while ago to use -Wno-format-zero-length, because it really is a silly complaint (it assumes there are no side effects of the function besides printing the format string, which is obviously not true in this case).

It would be nice to compile out of the box with "-Wall -Werror", and I think your solution looks relatively clean. But I am slightly concerned about the assumption that it is OK to pass a NULL fmt parameter to a function marked with __attribute__((format)). It certainly seems to be the case now, and I do not know of any plans for that to change, but it seems like a potentially obvious thing for the compiler to check.

I dunno; perhaps it has already been considered and rejected by gcc folks to allow the exact escape hatch we are using here.

-Peff
Previous: Benoit PierreNext: Junio C Hamano
Message 5 of 6 in “fix status_printf_ln calls "zero-length format" warnings”
  1. 0/2 fix status_printf_ln calls "zero-length format" warningsBenoit Pierre, Mar 10, 2014
  2. 1/2 status: allow NULL fmt for status_printf/status_vprintf_lnBenoit Pierre, Mar 10, 2014
  3. Eric SunshineMar 10, 2014
  4. 2/2 fix status_printf_ln calls "zero-length format" warningsBenoit Pierre, Mar 10, 2014
  5. Jeff KingMar 10, 2014
  6. Junio C HamanoMar 11, 2014

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.