From: larsxschneider@gmail.com Date: Wed, 03 Aug 2016 16:42:17 GMT Subject: [PATCH v4 04/12] pkt-line: call packet_trace() only if a packet is actually send Message-ID: <20160803164225.46355-5-larsxschneider@gmail.com> In-Reply-To: <20160803164225.46355-1-larsxschneider@gmail.com> From: Lars Schneider The packet_trace() call is not ideal in format_packet() as we would print a trace when a packet is formatted and (potentially) when the packet is actually send. This was no problem up until now because format_packet() was only used by one function. Fix it by moving the trace call into the function that actally sends the packet. Signed-off-by: Lars Schneider --- pkt-line.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkt-line.c b/pkt-line.c index c8a052a..d1368e6 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -127,7 +127,6 @@ static void format_packet(struct strbuf *out, const char *fmt, va_list args) die("protocol error: impossibly long line"); set_packet_header(&out->buf[orig_len], n); - packet_trace(out->buf + orig_len + 4, n - 4, 1); } void packet_write(int fd, const char *fmt, ...) @@ -139,6 +138,7 @@ void packet_write(int fd, const char *fmt, ...) va_start(args, fmt); format_packet(&buf, fmt, args); va_end(args); + packet_trace(buf.buf + 4, buf.len - 4, 1); write_or_die(fd, buf.buf, buf.len); } -- 2.9.0