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

Re: [PATCH 2/7] nfv?asprintf are broken without va_copy, workaround them.

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 20, 2007, 04:27 UTC
Message-ID
<7vwsumkll8.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1190241736-30449-3-git-send-email-madcoder@debian.org>
Pierre Habouzit <madcoder@debian.org> writes:
Show 7 quoted lines
> * drop nfasprintf.
> * move nfvasprintf into imap-send.c back, and let it work on a 8k buffer,
>   and die() in case of overflow. It should be enough for imap commands, if
>   someone cares about imap-send, he's welcomed to fix it properly.
> * replace nfvasprintf use in merge-recursive with a copy of the strbuf_addf
>   logic, it's one place, we'll live with it.
>   To ease the change, output_buffer string list is replaced with a strbuf ;)
While I'd agree with all of the above,
> * rework trace.c API's so that only one of the trace functions takes a
>   vararg. It's used to format strerror()s and git command names, it should
>   never be more than a few octets long, let it work on a 8k static buffer
>   with vsnprintf or die loudly.

and I'd agree with this in principle, there is a minor nit with the implementation and use in trace.c. E.g.

Show 11 quoted lines
> diff --git a/exec_cmd.c b/exec_cmd.c
> index 9b74ed2..c0f954e 100644
> --- a/exec_cmd.c
> +++ b/exec_cmd.c
> @@ -97,7 +97,8 @@ int execv_git_cmd(const char **argv)
>  		tmp = argv[0];
>  		argv[0] = git_command;
>  
> -		trace_argv_printf(argv, -1, "trace: exec:");
> +		trace_printf("trace: exec:");
> +		trace_argv(argv, -1);

This used to be a single call into trace.c which would format a single string to write(2) out. Now these two messages go through separate write(2) and can be broken up. I think the atomicity of the log/trace message was the primary reason the original had such a strange calling convention.

Previous: Pierre HabouzitNext: Christian Couder
Message 2 of 11 in “quote/strbuf series, take 3”
  1. Pierre HabouzitSep 19, 2007
  2. Junio C HamanoSep 20, 2007
  3. Christian CouderSep 20, 2007
  4. Pierre HabouzitSep 20, 2007
  5. 2/7 nfv?asprintf are broken without va_copy, workaround them.Pierre Habouzit, Sep 20, 2007
  6. Junio C HamanoSep 21, 2007
  7. Pierre HabouzitSep 21, 2007
  8. 4/7 sq_quote_argv and add_to_string rework with strbuf's.Pierre Habouzit, Sep 20, 2007
  9. Pierre HabouzitSep 20, 2007
  10. Pierre HabouzitSep 21, 2007
  11. 7/7 Pierre Habouzit, Sep 21, 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.