Re: [PATCH v4 01/12] pkt-line: extract set_packet_header()
- From
Jeff King <peff@peff.net>
- Date
- Aug 3, 2016, 21:27 UTC
- Message-ID
- <20160803212718.cdqhd2zfzce7mqfa@sigill.intra.peff.net>
- In-Reply-To
- <20160803211221.t2zdhvwjum2baeqs@sigill.intra.peff.net>
On Wed, Aug 03, 2016 at 05:12:21PM -0400, Jeff King wrote:
> The alternative is to hand-code it, which is what send_sideband() does
> (it uses xsnprintf("%04x") to do the hex formatting, though).After seeing that, I wondered why we need set_packet_header() at all. But we do for the case when we are filling in the size at the start of a buffer, because xsnprintf() will write an extra NUL that we do not care about. send_sideband() is happy to then overwrite it with data, but code (like format_packet) that computes the buffer, then fills in the size, must avoid overwriting the first byte of the buffer.
-Peff