aboutsummaryrefslogtreecommitdiffstats
path: root/mem-pool.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2024-04-21 14:40:28 +0200
committerJunio C Hamano <gitster@pobox.com>2024-04-21 12:27:07 -0700
commit0283cd5161561b29951c00697679c10b454e541a (patch)
treed28d1f098c6e7d1a927f4f23ba73e27cfd29230e /mem-pool.c
parentae3196a5ea84a9e88991d576020cf66512487088 (diff)
downloadgit-0283cd5161561b29951c00697679c10b454e541a.tar.gz
don't report vsnprintf(3) error as bug
strbuf_addf() has been reporting a negative return value of vsnprintf(3) as a bug since f141bd804d (Handle broken vsnprintf implementations in strbuf, 2007-11-13). Other functions copied that behavior: 7b03c89ebd (add xsnprintf helper function, 2015-09-24) 5ef264dbdb (strbuf.c: add `strbuf_insertf()` and `strbuf_vinsertf()`, 2019-02-25) 8d25663d70 (mem-pool: add mem_pool_strfmt(), 2024-02-25) However, vsnprintf(3) can legitimately return a negative value if the formatted output would be longer than INT_MAX. Stop accusing it of being broken and just report the fact that formatting failed. Suggested-by: Jeff King <peff@peff.net> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'mem-pool.c')
-rw-r--r--mem-pool.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mem-pool.c b/mem-pool.c
index 3065b12b23..a3ba38831d 100644
--- a/mem-pool.c
+++ b/mem-pool.c
@@ -4,6 +4,7 @@
#include "git-compat-util.h"
#include "mem-pool.h"
+#include "gettext.h"
#define BLOCK_GROWTH_SIZE (1024 * 1024 - sizeof(struct mp_block))
@@ -122,7 +123,7 @@ static char *mem_pool_strvfmt(struct mem_pool *pool, const char *fmt,
len = vsnprintf(next_free, available, fmt, cp);
va_end(cp);
if (len < 0)
- BUG("your vsnprintf is broken (returned %d)", len);
+ die(_("unable to format message: %s"), fmt);
size = st_add(len, 1); /* 1 for NUL */
ret = mem_pool_alloc(pool, size);