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

Re: [PATCH 1/6] Fix some "printf format" warnings.

From
Junio C Hamano <junkio@cox.net>
Date
Mar 3, 2007, 21:53 UTC
Message-ID
<7v4pp29eok.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<45E9BE46.1020801@ramsay1.demon.co.uk>
Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
Show 19 quoted lines
> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
> ---
>
> It's interesting to note that all of the warnings are caused by mismatching
> parameter expression involving a call to ntohl().
> [OK, it wasn't that interesting ;-)]
> diff --git a/builtin-ls-files.c b/builtin-ls-files.c
> index ac89eb2..5c990a5 100644
> --- a/builtin-ls-files.c
> +++ b/builtin-ls-files.c
> @@ -193,7 +193,7 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
>  		putchar(line_terminator);
>  	}
>  	else {
> -		printf("%s%06o %s %d\t",
> +		printf("%s%06lo %s %d\t",
>  		       tag,
>  		       ntohl(ce->ce_mode),
>  		       abbrev ? find_unique_abbrev(ce->sha1,abbrev)

I think the issue is ntohl() returns uint32_t, and this did not surface as an issue so far only because that type happens to be defined as 'unsigned int' on many systems. Changing %o to %lo is shifting the breakage to other systems, isn't it?

I think we should do this instead:
	printf("%s%06o %s %d\t", tag, (unsigned) ntohl(ce->ce_mode), ...
Previous: Ramsay JonesNext: Ramsay Jones
Message 2 of 8 in “Fix some "printf format" warnings.”
  1. 1/6 Fix some "printf format" warnings.Ramsay Jones, Mar 3, 2007
  2. Junio C HamanoMar 3, 2007
  3. Ramsay JonesMar 4, 2007
  4. Simon 'corecode' SchubertMar 12, 2007
  5. Junio C HamanoMar 12, 2007
  6. Ramsay JonesMar 14, 2007
  7. Junio C HamanoMar 14, 2007
  8. Ramsay JonesMar 13, 2007

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.