Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2022-03-07 18:27:08 +0300
committerJunio C Hamano <gitster@pobox.com>2022-03-07 23:02:04 +0300
commit99d60545f87445d7050999b826fc4cd49e69376c (patch)
tree04c2fd0bb6ace556283d146464ccb20204334002 /wt-status.c
parent6f69325258da2816445f8ee4bd028c0a167b31e8 (diff)
string-list API: change "nr" and "alloc" to "size_t"
Change the "nr" and "alloc" members of "struct string_list" to use "size_t" instead of "nr". On some platforms the size of an "unsigned int" will be smaller than a "size_t", e.g. a 32 bit unsigned v.s. 64 bit unsigned. As "struct string_list" is a generic API we use in a lot of places this might cause overflows. As one example: code in "refs.c" keeps track of the number of refs with a "size_t", and auxiliary code in builtin/remote.c in get_ref_states() appends those to a "struct string_list". While we're at it split the "nr" and "alloc" in string-list.h across two lines, which is the case for most such struct member declarations (e.g. in "strbuf.h" and "strvec.h"). Changing e.g. "int i" to "size_t i" in run_and_feed_hook() isn't strictly necessary, and there are a lot more cases where we'll use a local "int", "unsigned int" etc. variable derived from the "nr" in the "struct string_list". But in that case as well as add_wrapped_shortlog_msg() in builtin/shortlog.c we need to adjust the printf format referring to "nr" anyway, so let's also change the other variables referring to it. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r--wt-status.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/wt-status.c b/wt-status.c
index 335e723a71..bd54cf5989 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1374,10 +1374,10 @@ static void show_rebase_information(struct wt_status *s,
status_printf_ln(s, color, _("No commands done."));
else {
status_printf_ln(s, color,
- Q_("Last command done (%d command done):",
- "Last commands done (%d commands done):",
+ Q_("Last command done (%"PRIuMAX" command done):",
+ "Last commands done (%"PRIuMAX" commands done):",
have_done.nr),
- have_done.nr);
+ (uintmax_t)have_done.nr);
for (i = (have_done.nr > nr_lines_to_show)
? have_done.nr - nr_lines_to_show : 0;
i < have_done.nr;
@@ -1393,10 +1393,10 @@ static void show_rebase_information(struct wt_status *s,
_("No commands remaining."));
else {
status_printf_ln(s, color,
- Q_("Next command to do (%d remaining command):",
- "Next commands to do (%d remaining commands):",
+ Q_("Next command to do (%"PRIuMAX" remaining command):",
+ "Next commands to do (%"PRIuMAX" remaining commands):",
yet_to_do.nr),
- yet_to_do.nr);
+ (uintmax_t)yet_to_do.nr);
for (i = 0; i < nr_lines_to_show && i < yet_to_do.nr; i++)
status_printf_ln(s, color, " %s", yet_to_do.items[i].string);
if (s->hints)