From fbd09439c097123346d9823b88c87438bf5a11ae Mon Sep 17 00:00:00 2001 From: Maxim Moseychuk Date: Thu, 16 Feb 2017 20:07:13 +0300 Subject: stop_progress_msg: convert xsnprintf to xstrfmt Simplify code by replacing buffer allocation with a call to xstrfmt(). Signed-off-by: Maxim Moseychuk Signed-off-by: Junio C Hamano diff --git a/progress.c b/progress.c index 76a88c5..29378ca 100644 --- a/progress.c +++ b/progress.c @@ -243,21 +243,18 @@ void stop_progress_msg(struct progress **p_progress, const char *msg) *p_progress = NULL; if (progress->last_value != -1) { /* Force the last update */ - char buf[128], *bufp; - size_t len = strlen(msg) + 5; + char *buf; struct throughput *tp = progress->throughput; - bufp = (len < sizeof(buf)) ? buf : xmallocz(len); if (tp) { unsigned int rate = !tp->avg_misecs ? 0 : tp->avg_bytes / tp->avg_misecs; throughput_string(&tp->display, tp->curr_total, rate); } progress_update = 1; - xsnprintf(bufp, len + 1, ", %s.\n", msg); - display(progress, progress->last_value, bufp); - if (buf != bufp) - free(bufp); + buf = xstrfmt(", %s.\n", msg); + display(progress, progress->last_value, buf); + free(buf); } clear_progress_signal(); if (progress->throughput) -- cgit v0.10.2-6-g49f6 From 2cfa83574c4b2685208a1e6062fdc573c887cf00 Mon Sep 17 00:00:00 2001 From: Maxim Moseychuk Date: Thu, 16 Feb 2017 20:07:12 +0300 Subject: bisect_next_all: convert xsnprintf to xstrfmt Git can't run bisect between 2048+ commits if use russian translation, because the translated string is too long for the fixed buffer it uses (this can be reproduced "LANG=ru_RU.UTF8 git bisect start v4.9 v4.8" on linux sources). Use xstrfmt() to format the message string to sufficiently sized buffer instead to fix this. Signed-off-by: Maxim Moseychuk Signed-off-by: Junio C Hamano diff --git a/bisect.c b/bisect.c index 21bc6da..787543c 100644 --- a/bisect.c +++ b/bisect.c @@ -940,7 +940,7 @@ int bisect_next_all(const char *prefix, int no_checkout) struct commit_list *tried; int reaches = 0, all = 0, nr, steps; const unsigned char *bisect_rev; - char steps_msg[32]; + char *steps_msg; read_bisect_terms(&term_bad, &term_good); if (read_bisect_refs()) @@ -990,14 +990,15 @@ int bisect_next_all(const char *prefix, int no_checkout) nr = all - reaches - 1; steps = estimate_bisect_steps(all); - xsnprintf(steps_msg, sizeof(steps_msg), - Q_("(roughly %d step)", "(roughly %d steps)", steps), - steps); + + steps_msg = xstrfmt(Q_("(roughly %d step)", "(roughly %d steps)", + steps), steps); /* TRANSLATORS: the last %s will be replaced with "(roughly %d steps)" translation */ printf(Q_("Bisecting: %d revision left to test after this %s\n", "Bisecting: %d revisions left to test after this %s\n", nr), nr, steps_msg); + free(steps_msg); return bisect_checkout(bisect_rev, no_checkout); } -- cgit v0.10.2-6-g49f6