Change the "struct string_list" to have a "size_t" for "nr" and "alloc", ensuring we won't overflow on platforms where size_t is 64 bit, but "unsigned int" is 32 bit. This replaces the v1 1/2 to get rid of the casts we use for Q_(), and the 2/2's addition of casts is then consistent with those. Ævar Arnfjörð Bjarmason (2): gettext API users: don't explicitly cast ngettext()'s "n" string-list API: change "nr" and "alloc" to "size_t" builtin/index-pack.c | 2 +- builtin/merge-recursive.c | 2 +- builtin/receive-pack.c | 9 +++++---- builtin/shortlog.c | 10 +++++----- bundle.c | 8 ++++---- commit-graph.c | 6 +++--- mailmap.c | 7 ++++--- merge-ort.c | 4 ++-- strbuf.c | 4 ++-- string-list.h | 3 ++- t/helper/test-run-command.c | 7 ++++--- wt-status.c | 12 ++++++------ 12 files changed, 39 insertions(+), 35 deletions(-) Range-diff against v1: 1: 83659fbc459 < -: ----------- gettext API users: correct use of casts for Q_() -: ----------- > 1: 83fd21741ad gettext API users: don't explicitly cast ngettext()'s "n" 2: 398682c07aa ! 2: 6db8ab7a121 string-list API: change "nr" and "alloc" to "size_t" @@ Commit message 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@xxxxxxxxx> ## builtin/receive-pack.c ## @@ bundle.c: int verify_bundle(struct repository *r, r = &header->references; printf_ln(Q_("The bundle contains this ref:", - "The bundle contains these %d refs:", -- r->nr), -- r->nr); + "The bundle contains these %"PRIuMAX" refs:", -+ (unsigned long)r->nr), + r->nr), +- r->nr); + (uintmax_t)r->nr); list_refs(r, 0, NULL); r = &header->prerequisites; @@ bundle.c: int verify_bundle(struct repository *r, } else { printf_ln(Q_("The bundle requires this ref:", - "The bundle requires these %d refs:", -- r->nr), -- r->nr); + "The bundle requires these %"PRIuMAX" refs:", -+ (unsigned long)r->nr), + r->nr), +- r->nr); + (uintmax_t)r->nr); list_refs(r, 0, NULL); } @@ commit-graph.c: static int fill_oids_from_packs(struct write_commit_graph_contex strbuf_addf(&progress_title, - Q_("Finding commits for commit graph in %d pack", - "Finding commits for commit graph in %d packs", -- pack_indexes->nr), -- pack_indexes->nr); + Q_("Finding commits for commit graph in %"PRIuMAX" pack", + "Finding commits for commit graph in %"PRIuMAX" packs", -+ (unsigned long)pack_indexes->nr), + pack_indexes->nr), +- pack_indexes->nr); + (uintmax_t)pack_indexes->nr); ctx->progress = start_delayed_progress(progress_title.buf, 0); ctx->progress_done = 0; @@ wt-status.c: static void show_rebase_information(struct wt_status *s, status_printf_ln(s, color, - Q_("Last command done (%d command done):", - "Last commands done (%d commands done):", -- have_done.nr), -- have_done.nr); + Q_("Last command done (%"PRIuMAX" command done):", + "Last commands done (%"PRIuMAX" commands done):", -+ (unsigned long)have_done.nr), + 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; @@ wt-status.c: static void show_rebase_information(struct wt_status *s, status_printf_ln(s, color, - Q_("Next command to do (%d remaining command):", - "Next commands to do (%d remaining commands):", -- yet_to_do.nr), -- yet_to_do.nr); + Q_("Next command to do (%"PRIuMAX" remaining command):", + "Next commands to do (%"PRIuMAX" remaining commands):", -+ (unsigned long)yet_to_do.nr), + 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); -- 2.35.1.1242.gfeba0eae32b