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

Re: [PATCH 2/2 jk/war-on-sprintf] compat/mingw.c: remove printf format warning

From
Jeff King <peff@peff.net>
Date
Oct 23, 2015, 11:20 UTC
Message-ID
<20151023112019.GB14996@sigill.intra.peff.net>
In-Reply-To
<28a610a30ab9d4f742be2f3225db341ea40c8a51.1445579874.git.j6t@kdbg.org>
On Fri, Oct 23, 2015 at 08:02:52AM +0200, Johannes Sixt wrote:
Show 15 quoted lines
> 5096d490 (convert trivial sprintf / strcpy calls to xsnprintf) converted
> two sprintf calls. Now GCC warns that "format '%u' expects argument of
> type 'unsigned int', but argument 4 has type 'long unsigned int'".
> Instead of changing the format string, use a variable of type unsigned
> in place of the typedef-ed type DWORD, which hides that it is actually an
> unsigned long.
> 
> There is no correctness issue with the old code because unsigned long and
> unsigned are always of the same size on Windows, even in 64-bit builds.
> 
> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
> ---
> I do not know why there are no warnings with the old code. Apparently, the
> system provided sprintf declaration does not have format-printf
> annotation.
Makes sense, and the patch looks obviously correct.
-Peff
Previous: Johannes SixtNext: Jeff King
Message 3 of 5 in “read_branches_file: plug a FILE* leak”
  1. 1/2 read_branches_file: plug a FILE* leakJohannes Sixt, Oct 23, 2015
  2. 2/2 compat/mingw.c: remove printf format warningJohannes Sixt, Oct 23, 2015
  3. Jeff KingOct 23, 2015
  4. Jeff KingOct 23, 2015
  5. Junio C HamanoOct 23, 2015

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.