From: Lars Schneider <larsxschneider@xxxxxxxxx> set_packet_header() converts an integer to a 4 byte hex string. Make this function locally available so that other pkt-line functions can use it. Signed-off-by: Lars Schneider <larsxschneider@xxxxxxxxx> --- pkt-line.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkt-line.c b/pkt-line.c index 62fdb37..445b8e1 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -98,9 +98,17 @@ void packet_buf_flush(struct strbuf *buf) } #define hex(a) (hexchar[(a) & 15]) -static void format_packet(struct strbuf *out, const char *fmt, va_list args) +static void set_packet_header(char *buf, const int size) { static char hexchar[] = "0123456789abcdef"; + buf[0] = hex(size >> 12); + buf[1] = hex(size >> 8); + buf[2] = hex(size >> 4); + buf[3] = hex(size); +} + +static void format_packet(struct strbuf *out, const char *fmt, va_list args) +{ size_t orig_len, n; orig_len = out->len; @@ -111,10 +119,7 @@ static void format_packet(struct strbuf *out, const char *fmt, va_list args) if (n > LARGE_PACKET_MAX) die("protocol error: impossibly long line"); - out->buf[orig_len + 0] = hex(n >> 12); - out->buf[orig_len + 1] = hex(n >> 8); - out->buf[orig_len + 2] = hex(n >> 4); - out->buf[orig_len + 3] = hex(n); + set_packet_header(&out->buf[orig_len], n); packet_trace(out->buf + orig_len + 4, n - 4, 1); } -- 2.9.0 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html