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

Re: [PATCH 2/2] commit: use strbuf_add() to add a buffer to a strbuf

From
Jeff King <peff@peff.net>
Date
Oct 2, 2017, 05:18 UTC
Message-ID
<20171002051855.f3g2sz32ysjd6xu4@sigill.intra.peff.net>
In-Reply-To
<223ef0c8-dac2-747b-41c8-3bad62f4c274@web.de>
On Sun, Oct 01, 2017 at 04:54:14PM +0200, René Scharfe wrote:
> This is shorter, easier and makes the intent clearer.
> 
> Patch generated with Coccinelle and contrib/coccinelle/strbuf.cocci.

Technically this behaves differently if there is a NUL embedded in the string. I'd expect that to be unlikely in most cases. And when it is possible, I'd venture to say that the new behavior is likely to be the correct one.

This case is fine (and any embedded NUL would be cut off by setenv anyway). As a general transformation, this is not as obviously safe as many of the others. But since we eyeball the output of coccinelle anyway, it should be fine (and any code which is _relying_ on that behavior really ought to be rewritten in a less subtle way).

-Peff
Previous: René Scharfe
Message 3 of 3 in “coccinelle: add rules to use strbuf_add() for adding buffers to strbufs”
  1. 1/2 coccinelle: add rules to use strbuf_add() for adding buffers to strbufsRené Scharfe, Oct 1, 2017
  2. 2/2 commit: use strbuf_add() to add a buffer to a strbufRené Scharfe, Oct 1, 2017
  3. Jeff KingOct 2, 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.