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

Re: [PATCH] fast-export: avoid NULL pointer arithmetic

From
Duy Nguyen <pclouds@gmail.com>
Date
May 11, 2018, 06:19 UTC
Message-ID
<CACsJy8AN4nssu1+x0x9Kmz1BB1aXO7_UBFCjpyULMeC5K-Fzvw@mail.gmail.com>
In-Reply-To
<xmqq7eoahk49.fsf@gitster-ct.c.googlers.com>
On Fri, May 11, 2018 at 6:49 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 22 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> René Scharfe <l.s.r@web.de> writes:
>>
>>>> But it somehow feels backwards in spirit to me, as the reason why we
>>>> use "void *" there in the decoration field is because we expect that
>>>> we'd have a pointer to some struture most of the time, and we have
>>>> to occasionally store a small integer there.
>>>
>>> Yes, fast-export seems to be the only place that stores an integer as
>>> a decoration.
>>
>> With the decoration subsystem that might be the case, but I think
>> we have other codepaths where "void * .util" field in the structure
>> is used to store (void *)1, expecting that a normal allocation will
>> never yield a pointer that is indistinguishable from that value.
>
> I was looking at a different topic and noticed that bisect.c uses
> commit->util (which is of type "void *") to always store an int (it
> never stores a pointer and there is no mixing).  This one is equally
> unportable as fast-export after your fix.
>

In both cases we should be able to use commit-slab instead of commit->util. We could go even further and kill "util" pointer but that's more work.

-- 
Duy
Previous: Junio C HamanoNext: Jeff King
Message 8 of 16 in “fast-export: avoid NULL pointer arithmetic”
  1. fast-export: avoid NULL pointer arithmeticRené Scharfe, May 9, 2018
  2. Johannes SchindelinMay 9, 2018
  3. René ScharfeMay 10, 2018
  4. Junio C HamanoMay 10, 2018
  5. René ScharfeMay 10, 2018
  6. Junio C HamanoMay 11, 2018
  7. Junio C HamanoMay 11, 2018
  8. Duy NguyenMay 11, 2018
  9. Jeff KingMay 11, 2018
  10. Duy NguyenMay 11, 2018
  11. Duy NguyenMay 11, 2018
  12. Jeff KingMay 11, 2018
  13. René ScharfeMay 12, 2018
  14. René ScharfeMay 12, 2018
  15. Junio C HamanoMay 14, 2018
  16. René ScharfeMay 15, 2018

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.