git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] string-list API: change "nr" and "alloc" to "size_t"

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Mar 7, 2022, 14:10 UTC
Message-ID
<220307.86sfrtzwdg.gmgdl@evledraar.gmail.com>
In-Reply-To
<34eb7b5a-180c-0e4a-0929-8eaf52f80090@github.com>
On Mon, Mar 07 2022, Derrick Stolee wrote:
Show 19 quoted lines
> 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.
Previous: Derrick StoleeNext: Ævar Arnfjörð Bjarmason
Message 8 of 15 in “string-list.h: make "nr" and "alloc" a "size_t"”
  1. 0/2 string-list.h: make "nr" and "alloc" a "size_t"Ævar Arnfjörð Bjarmason, Mar 7, 2022
  2. 1/2 gettext API users: correct use of casts for Q_()Ævar Arnfjörð Bjarmason, Mar 7, 2022
  3. Derrick StoleeMar 7, 2022
  4. Ævar Arnfjörð BjarmasonMar 7, 2022
  5. Derrick StoleeMar 7, 2022
  6. 2/2 string-list API: change "nr" and "alloc" to "size_t"Ævar Arnfjörð Bjarmason, Mar 7, 2022
  7. Derrick StoleeMar 7, 2022
  8. Ævar Arnfjörð BjarmasonMar 7, 2022
  9. 0/2 string-list.h: make "nr" and "alloc" a "size_t"Ævar Arnfjörð Bjarmason, Mar 7, 2022
  10. 1/2 gettext API users: don't explicitly cast ngettext()'s "n"Ævar Arnfjörð Bjarmason, Mar 7, 2022
  11. 2/2 string-list API: change "nr" and "alloc" to "size_t"Ævar Arnfjörð Bjarmason, Mar 7, 2022
  12. Philip OakleyMar 7, 2022
  13. Junio C HamanoMar 7, 2022
  14. Philip OakleyMar 7, 2022
  15. Derrick StoleeMar 7, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.