Thread (132 messages) 132 messages, 8 authors, 2021-03-22

Re: [PATCH v2 03/14] pkt-line: add write_packetized_from_buf2() that takes scratch buffer

flat view

From: Jeff King <hidden>
Date: 2021-02-02 09:45:50

On Mon, Feb 01, 2021 at 07:45:36PM +0000, Jeff Hostetler via GitGitGadget wrote:
From: Jeff Hostetler <redacted>

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...
quoted hunk ↗ jump to hunk
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help