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

Re: [PATCH] wt-status.c: disable those distracting -Wformat-zero-length warnings

From
Jeff King <peff@peff.net>
Date
Dec 21, 2013, 09:42 UTC
Message-ID
<20131221094202.GA32622@sigill.intra.peff.net>
In-Reply-To
<1387554301-23901-1-git-send-email-naesten@gmail.com>
On Fri, Dec 20, 2013 at 10:45:01AM -0500, Samuel Bronson wrote:
> These warnings don't really seem to make much sense for this file.

Agreed, though the advice so far has been to put -Wno-format-zero-length in your CFLAGS.

> +/* We have good reasons for using zero-length format strings, and
> + * there's unfortunately no way to turn this off on a per-function
> + * basis ... */
> +#pragma GCC diagnostic ignored "-Wformat-zero-length"

Are other compilers happy to ignore this pragma? I guess we could wrap it in an #ifdef, if so.

It's also really not about this file in particular. The whole concept of format-zero-length is questionable, as it ignores the concept that a format function might actually do something useful with an empty format (e.g., by adding boilerplate, or having a side-effect). It's just that this file is the only one that happens to do so.

Annotating the _function_ to say "it's useful to pass an empty format into this function" would make sense, but as you note, there is no way to do that.

So I dunno. This seems like it does not quite specify what we want to say as well as just "-Wno-format-zero-length", but it is more convenient in practice (because we take care of it in the source code, rather than relying on the user's build settings).

-Peff
Previous: Samuel BronsonNext: Samuel Bronson
Message 2 of 3 in “wt-status.c: disable those distracting -Wformat-zero-length warnings”
  1. wt-status.c: disable those distracting -Wformat-zero-length warningsSamuel Bronson, Dec 20, 2013
  2. Jeff KingDec 21, 2013
  3. Samuel BronsonDec 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.