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

Re: [PATCH 1/3] add git_psprintf helper function

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Feb 16, 2017, 15:51 UTC
Message-ID
<616a2b08-71f9-d594-d46c-2687bf20ae2b@google.com>
In-Reply-To
<20170216112829.18079-2-franchesko.salias.hudro.pedros@gmail.com>
On 02/16/2017 03:28 AM, Maxim Moseychuk wrote:
Show 13 quoted lines
> There are a number of places in the code where we call
> xsnprintf(), with the assumption that the output will fit into
> the buffer. If the buffer is small, then git die.
> In many places buffers have compile-time size, but generated string
> depends from current system locale (gettext)and can have size
> greater the buffer.
> Just run "LANG=ru_RU.UTF8 git bisect start v4.9 v4.8"
> on linux sources - it impossible.
>
> git_psprintf is similar to the standard C sprintf() function
> but safer, since it calculates the maximum space required
> and allocates memory to hold the result.
> The returned string should be freed with free() when no longer needed.

If I understand this correctly, xstrfmt (in strbuf.h) should already do what you need, so you do not need a new function.

Previous: Maxim MoseychukNext: Jeff King
Message 3 of 9 in “Fix l10n”
  1. 0/3 Fix l10nMaxim Moseychuk, Feb 16, 2017
  2. 1/3 add git_psprintf helper functionMaxim Moseychuk, Feb 16, 2017
  3. Jonathan TanFeb 16, 2017
  4. Jeff KingFeb 16, 2017
  5. 3/3 stop_progress_msg: convert xsnprintf to git_psprintfMaxim Moseychuk, Feb 16, 2017
  6. Jeff KingFeb 16, 2017
  7. 2/3 bisect_next_all: convert xsnprintf to git_psprintfMaxim Moseychuk, Feb 16, 2017
  8. Jeff KingFeb 16, 2017
  9. Jeff KingFeb 16, 2017

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.