From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Derrick Stolee <derrickstolee@github.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Taylor Blau <me@ttaylorr.com>
Subject: Re: [PATCH 2/2] string-list API: change "nr" and "alloc" to "size_t"
Date: Mon, 07 Mar 2022 15:10:23 +0100 [thread overview]
Message-ID: <220307.86sfrtzwdg.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <34eb7b5a-180c-0e4a-0929-8eaf52f80090@github.com>
On Mon, Mar 07 2022, Derrick Stolee wrote:
> On 3/7/2022 6:38 AM, Ævar Arnfjörð Bjarmason wrote:
>> 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.
>>
>
>> 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),
>> + (uintmax_t)r->nr);
>
> There are more additions of unsigned long here, which will possibly
> truncate the size_t of r->nr. I must be missing something here that
> explains why you are making this choice.
Replied to in the reply to your comment on 1/2.
next prev parent reply other threads:[~2022-03-07 14:10 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 [this message]
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
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=220307.86sfrtzwdg.gmgdl@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=me@ttaylorr.com \
/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).