Skip to content

Commit 38bbb9e

Browse files
committed
Merge branch 'ab/string-list-count-in-size-t'
Count string_list items in size_t, not "unsigned int". * ab/string-list-count-in-size-t: string-list API: change "nr" and "alloc" to "size_t" gettext API users: don't explicitly cast ngettext()'s "n"
2 parents 7431379 + 99d6054 commit 38bbb9e

File tree

12 files changed

+39
-35
lines changed

12 files changed

+39
-35
lines changed

builtin/index-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ static void *unpack_data(struct object_entry *obj,
582582
if (!n)
583583
die(Q_("premature end of pack file, %"PRIuMAX" byte missing",
584584
"premature end of pack file, %"PRIuMAX" bytes missing",
585-
(unsigned int)len),
585+
len),
586586
(uintmax_t)len);
587587
from += n;
588588
len -= n;

builtin/merge-recursive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
5858
"Ignoring %s.",
5959
"cannot handle more than %d bases. "
6060
"Ignoring %s.",
61-
(int)ARRAY_SIZE(bases)-1),
61+
ARRAY_SIZE(bases)-1),
6262
(int)ARRAY_SIZE(bases)-1, argv[i]);
6363
}
6464
if (argc - i != 3) /* "--" "<head>" "<remote>" */

builtin/receive-pack.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -813,13 +813,14 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed,
813813
proc.trace2_hook_name = hook_name;
814814

815815
if (feed_state->push_options) {
816-
int i;
816+
size_t i;
817817
for (i = 0; i < feed_state->push_options->nr; i++)
818818
strvec_pushf(&proc.env_array,
819-
"GIT_PUSH_OPTION_%d=%s", i,
819+
"GIT_PUSH_OPTION_%"PRIuMAX"=%s",
820+
(uintmax_t)i,
820821
feed_state->push_options->items[i].string);
821-
strvec_pushf(&proc.env_array, "GIT_PUSH_OPTION_COUNT=%d",
822-
feed_state->push_options->nr);
822+
strvec_pushf(&proc.env_array, "GIT_PUSH_OPTION_COUNT=%"PRIuMAX"",
823+
(uintmax_t)feed_state->push_options->nr);
823824
} else
824825
strvec_pushf(&proc.env_array, "GIT_PUSH_OPTION_COUNT");
825826

builtin/shortlog.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ static void add_wrapped_shortlog_msg(struct strbuf *sb, const char *s,
435435

436436
void shortlog_output(struct shortlog *log)
437437
{
438-
int i, j;
438+
size_t i, j;
439439
struct strbuf sb = STRBUF_INIT;
440440

441441
if (log->sort_by_number)
@@ -448,10 +448,10 @@ void shortlog_output(struct shortlog *log)
448448
(int)UTIL_TO_INT(item), item->string);
449449
} else {
450450
struct string_list *onelines = item->util;
451-
fprintf(log->file, "%s (%d):\n",
452-
item->string, onelines->nr);
453-
for (j = onelines->nr - 1; j >= 0; j--) {
454-
const char *msg = onelines->items[j].string;
451+
fprintf(log->file, "%s (%"PRIuMAX"):\n",
452+
item->string, (uintmax_t)onelines->nr);
453+
for (j = onelines->nr; j >= 1; j--) {
454+
const char *msg = onelines->items[j - 1].string;
455455

456456
if (log->wrap_lines) {
457457
strbuf_reset(&sb);

bundle.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,18 @@ int verify_bundle(struct repository *r,
255255

256256
r = &header->references;
257257
printf_ln(Q_("The bundle contains this ref:",
258-
"The bundle contains these %d refs:",
258+
"The bundle contains these %"PRIuMAX" refs:",
259259
r->nr),
260-
r->nr);
260+
(uintmax_t)r->nr);
261261
list_refs(r, 0, NULL);
262262
r = &header->prerequisites;
263263
if (!r->nr) {
264264
printf_ln(_("The bundle records a complete history."));
265265
} else {
266266
printf_ln(Q_("The bundle requires this ref:",
267-
"The bundle requires these %d refs:",
267+
"The bundle requires these %"PRIuMAX" refs:",
268268
r->nr),
269-
r->nr);
269+
(uintmax_t)r->nr);
270270
list_refs(r, 0, NULL);
271271
}
272272
}

commit-graph.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,10 +1698,10 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,
16981698
dirlen = packname.len;
16991699
if (ctx->report_progress) {
17001700
strbuf_addf(&progress_title,
1701-
Q_("Finding commits for commit graph in %d pack",
1702-
"Finding commits for commit graph in %d packs",
1701+
Q_("Finding commits for commit graph in %"PRIuMAX" pack",
1702+
"Finding commits for commit graph in %"PRIuMAX" packs",
17031703
pack_indexes->nr),
1704-
pack_indexes->nr);
1704+
(uintmax_t)pack_indexes->nr);
17051705
ctx->progress = start_delayed_progress(progress_title.buf, 0);
17061706
ctx->progress_done = 0;
17071707
}

mailmap.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ static void free_mailmap_info(void *p, const char *s)
4343
static void free_mailmap_entry(void *p, const char *s)
4444
{
4545
struct mailmap_entry *me = (struct mailmap_entry *)p;
46-
debug_mm("mailmap: removing entries for <%s>, with %d sub-entries\n",
47-
s, me->namemap.nr);
46+
debug_mm("mailmap: removing entries for <%s>, with %"PRIuMAX" sub-entries\n",
47+
s, (uintmax_t)me->namemap.nr);
4848
debug_mm("mailmap: - simple: '%s' <%s>\n",
4949
debug_str(me->name), debug_str(me->email));
5050

@@ -250,7 +250,8 @@ int read_mailmap(struct string_list *map)
250250

251251
void clear_mailmap(struct string_list *map)
252252
{
253-
debug_mm("mailmap: clearing %d entries...\n", map->nr);
253+
debug_mm("mailmap: clearing %"PRIuMAX" entries...\n",
254+
(uintmax_t)map->nr);
254255
map->strdup_strings = 1;
255256
string_list_clear_func(map, free_mailmap_entry);
256257
debug_mm("mailmap: cleared\n");

merge-ort.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4064,8 +4064,8 @@ static void process_entries(struct merge_options *opt,
40644064
trace2_region_enter("merge", "process_entries cleanup", opt->repo);
40654065
if (dir_metadata.offsets.nr != 1 ||
40664066
(uintptr_t)dir_metadata.offsets.items[0].util != 0) {
4067-
printf("dir_metadata.offsets.nr = %d (should be 1)\n",
4068-
dir_metadata.offsets.nr);
4067+
printf("dir_metadata.offsets.nr = %"PRIuMAX" (should be 1)\n",
4068+
(uintmax_t)dir_metadata.offsets.nr);
40694069
printf("dir_metadata.offsets.items[0].util = %u (should be 0)\n",
40704070
(unsigned)(uintptr_t)dir_metadata.offsets.items[0].util);
40714071
fflush(stdout);

strbuf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,9 +875,9 @@ static void strbuf_humanise(struct strbuf *buf, off_t bytes,
875875
strbuf_addf(buf,
876876
humanise_rate == 0 ?
877877
/* TRANSLATORS: IEC 80000-13:2008 byte */
878-
Q_("%u byte", "%u bytes", (unsigned)bytes) :
878+
Q_("%u byte", "%u bytes", bytes) :
879879
/* TRANSLATORS: IEC 80000-13:2008 byte/second */
880-
Q_("%u byte/s", "%u bytes/s", (unsigned)bytes),
880+
Q_("%u byte/s", "%u bytes/s", bytes),
881881
(unsigned)bytes);
882882
}
883883
}

string-list.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ typedef int (*compare_strings_fn)(const char *, const char *);
8686
*/
8787
struct string_list {
8888
struct string_list_item *items;
89-
unsigned int nr, alloc;
89+
size_t nr;
90+
size_t alloc;
9091
unsigned int strdup_strings:1;
9192
compare_strings_fn cmp; /* NULL uses strcmp() */
9293
};

0 commit comments

Comments
 (0)