From: Junio C Hamano <gitster@pobox.com>
To: Philip Oakley <philipoakley@iee.email>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
git@vger.kernel.org, "Taylor Blau" <me@ttaylorr.com>,
"Derrick Stolee" <derrickstolee@github.com>
Subject: Re: [PATCH v2 2/2] string-list API: change "nr" and "alloc" to "size_t"
Date: Mon, 07 Mar 2022 12:43:43 -0800 [thread overview]
Message-ID: <xmqqy21lqyrk.fsf@gitster.g> (raw)
In-Reply-To: <9c9ca557-122e-3bcb-db4b-3b5ba7bf9369@iee.email> (Philip Oakley's message of "Mon, 7 Mar 2022 16:23:07 +0000")
Philip Oakley <philipoakley@iee.email> writes:
>> @@ -448,10 +448,10 @@ void shortlog_output(struct shortlog *log)
>> (int)UTIL_TO_INT(item), item->string);
>> } else {
>> struct string_list *onelines = item->util;
>> - fprintf(log->file, "%s (%d):\n",
>> - item->string, onelines->nr);
>> - for (j = onelines->nr - 1; j >= 0; j--) {
>> - const char *msg = onelines->items[j].string;
>> + fprintf(log->file, "%s (%"PRIuMAX"):\n",
>> + item->string, (uintmax_t)onelines->nr);
>> + for (j = onelines->nr; j >= 1; j--) {
>> + const char *msg = onelines->items[j - 1].string;
> Does this change of iteration limits and j's offset need a commit
> message comment?
Good eyes. I also tried to made sure this is the only loop that
counts toward zero that use a variable whose type has become size_t
with this patch, which is unsigned and cannot use "var >= 0" as the
loop termination condition, but what is not in the patch is hard to
know. If there were loops that used to count down with the .nr or
the .alloc members of string_list structure, they would need to be
updated, but if such a code exists, it is likely a bug already.
I think many internal index string-list.c uses are still "int"
(cf. get_entry_index() and functions on the call graph that leads to
it, like add_entry() and string_list_remove()) that wants to be
updated to "ssize_t"; if the string_list has very many elements,
add_entry() may not find an existing string and add a duplicate at
the end, because the bisection search get_entry_index() uses cannot
move the upper-bound pointer beyond "int".
It would have been better if you culled the parts of the patch you
are not referring to, by the way.
Thanks.
next prev parent reply other threads:[~2022-03-07 20:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-07 11:37 [PATCH 0/2] string-list.h: make "nr" and "alloc" a "size_t" Ævar Arnfjörð Bjarmason
2022-03-07 11:38 ` [PATCH 1/2] gettext API users: correct use of casts for Q_() Ævar Arnfjörð Bjarmason
2022-03-07 13:41 ` Derrick Stolee
2022-03-07 13:54 ` Ævar Arnfjörð Bjarmason
2022-03-07 15:53 ` Derrick Stolee
2022-03-07 11:38 ` [PATCH 2/2] string-list API: change "nr" and "alloc" to "size_t" Ævar Arnfjörð Bjarmason
2022-03-07 13:43 ` Derrick Stolee
2022-03-07 14:10 ` Ævar Arnfjörð Bjarmason
2022-03-07 15:27 ` [PATCH v2 0/2] string-list.h: make "nr" and "alloc" a "size_t" Ævar Arnfjörð Bjarmason
2022-03-07 15:27 ` [PATCH v2 1/2] gettext API users: don't explicitly cast ngettext()'s "n" Ævar Arnfjörð Bjarmason
2022-03-07 15:27 ` [PATCH v2 2/2] string-list API: change "nr" and "alloc" to "size_t" Ævar Arnfjörð Bjarmason
2022-03-07 16:23 ` Philip Oakley
2022-03-07 20:43 ` Junio C Hamano [this message]
2022-03-07 23:34 ` Philip Oakley
2022-03-07 15:55 ` [PATCH v2 0/2] string-list.h: make "nr" and "alloc" a "size_t" Derrick Stolee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqy21lqyrk.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=me@ttaylorr.com \
--cc=philipoakley@iee.email \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).