Re: [PATCH v2 03/14] pkt-line: add write_packetized_from_buf2() that takes scratch buffer
- From
Jeff King <peff@peff.net>
- Date
- Feb 2, 2021, 09:44 UTC
- Message-ID
- <YBke/evrHFAC0se1@coredump.intra.peff.net>
- In-Reply-To
- <e671894b4c0419138e66270aa9699053bdd504be.1612208747.git.gitgitgadget@gmail.com>
On Mon, Feb 01, 2021 at 07:45:36PM +0000, Jeff Hostetler via GitGitGadget wrote:
Show 5 quoted lines
> From: Jeff Hostetler <jeffhost@microsoft.com> > > Create version of `write_packetized_from_buf()` that takes a scratch buffer > argument rather than assuming a static buffer. This will be used later as > we make packet-line writing more thread-safe.
OK, this is extending the changes from the first patch...
Show 9 quoted lines
> int write_packetized_from_buf(const char *src_in, size_t len, int fd_out)
> {
> static struct packet_scratch_space scratch;
> +
> + return write_packetized_from_buf2(src_in, len, fd_out, &scratch);
> +}
> +
> +int write_packetized_from_buf2(const char *src_in, size_t len, int fd_out,
> + struct packet_scratch_space *scratch)Oof, that name. I know we are guilty of a lot of "foo_1()" helpers for foo(), but they are usually internal static functions that don't get spread around. This one is a public function.
Something like "_with_scratch" might be a bit more descriptive. Though given that there is exactly one caller of the original currently, I'd be tempted to say that it should just learn the scratch-space argument.
(All of this is moot, of course, if you follow either of my suggestions from the earlier patch to drop the need for this scratch space entirely).
-Peff