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>
This commit is contained in:
committed by
Junio C Hamano
parent
6f69325258
commit
99d60545f8
@ -180,15 +180,16 @@ static int testsuite(int argc, const char **argv)
|
||||
if (max_jobs > suite.tests.nr)
|
||||
max_jobs = suite.tests.nr;
|
||||
|
||||
fprintf(stderr, "Running %d tests (%d at a time)\n",
|
||||
suite.tests.nr, max_jobs);
|
||||
fprintf(stderr, "Running %"PRIuMAX" tests (%d at a time)\n",
|
||||
(uintmax_t)suite.tests.nr, max_jobs);
|
||||
|
||||
ret = run_processes_parallel(max_jobs, next_test, test_failed,
|
||||
test_finished, &suite);
|
||||
|
||||
if (suite.failed.nr > 0) {
|
||||
ret = 1;
|
||||
fprintf(stderr, "%d tests failed:\n\n", suite.failed.nr);
|
||||
fprintf(stderr, "%"PRIuMAX" tests failed:\n\n",
|
||||
(uintmax_t)suite.failed.nr);
|
||||
for (i = 0; i < suite.failed.nr; i++)
|
||||
fprintf(stderr, "\t%s\n", suite.failed.items[i].string);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user