diff options
author | Jeff King <peff@peff.net> | 2015-09-24 17:05:57 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-09-25 10:18:18 -0700 |
commit | 3131977de1476185209d4d56a0494f5b30ee5557 (patch) | |
tree | c78667db915c3fcb1add2b73c20fcc6e47a6a90f /t/t7605-merge-resolve.sh | |
parent | trace: use strbuf for quote_crnl output (diff) | |
download | tgif-3131977de1476185209d4d56a0494f5b30ee5557.tar.xz |
progress: store throughput display in a strbuf
Coverity noticed that we strncpy() into a fixed-size buffer
without making sure that it actually ended up
NUL-terminated. This is unlikely to be a bug in practice,
since throughput strings rarely hit 32 characters, but it
would be nice to clean it up.
The most obvious way to do so is to add a NUL-terminator.
But instead, this patch switches the fixed-size buffer out
for a strbuf. At first glance this seems much less
efficient, until we realize that filling in the fixed-size
buffer is done by writing into a strbuf and copying the
result!
By writing straight to the buffer, we actually end up more
efficient:
1. We avoid an extra copy of the bytes.
2. Rather than malloc/free each time progress is shown, we
can strbuf_reset and use the same buffer each time.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7605-merge-resolve.sh')
0 files changed, 0 insertions, 0 deletions