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

Re: [PATCH v2 2/3] textconv: support for blame

From
Bbonneta <bonneta@ensimag.fr>
Date
Jun 15, 2010, 12:13 UTC
Message-ID
<d15348c8322f5f99aa1f330d32e0ddd4@ensimag.fr>
In-Reply-To
<20100615110710.GA1682@sigill.intra.peff.net>
On Tue, 15 Jun 2010 07:07:10 -0400, Jeff King <peff@peff.net> wrote:
Show 43 quoted lines
> [resending to cc git@vger]
> 
> On Tue, Jun 15, 2010 at 12:29:43PM +0200, bonneta wrote:
> 
>> We have changed the declaration of textconv_object() to:
>> 
>> static int textconv_object(const char *path,
>>                            const unsigned char *sha1,
>>                            char **buf,
>>                            unsigned long *buf_size)
>> 
>> And now we can do:
>> *buf_size = fill_textconv(textconv, df, buf);
>> without any cast.
> 
> I assume you mean dropping the final buf_size parameter from that
> declaration, which is what your usage example has. I would return either
> an "unsigned long" or a size_t rather than an int. We are dealing with
> potential whole-file sizes, so it is better to use at least as large a
> data type as other parts of the code (we still may run into truncation
> problems, but at least you are not making things any worse).
> 
>> But we have to do:
>> textconv_object(read_from, null_sha1, &buf.buf, (unsigned long *)
>> &buf.len))
>> where buf.len is size_t.
>> 
>> Is that ok?
> 
> No, that has the same problem. Imagine a big endian machine with a
> 32-bit unsigned long and a 64-bit size_t. You would write into the first
> 32 bits of buf.len, which are the high bits, giving you a ridiculously
> large answer.
> 
> The only portable way in C to convert between types is by assignment. So
> you have to do:
> 
>   unsigned long foo;
>   textconv_object(read_from, null_sha1, &buf.buf, &foo);
>   buf.len = foo;
> 
> But now I'm confused. That matches the declaration you gave in the first
> part of your email, but not the usage example.

We now understand what we have to do, thank you. We are currently fixing this patch. Do we have to resend only this patch or the whole series?

Previous: Jeff King
Message 17 of 17 in “textconv support for blame”
  1. 0/3 textconv support for blameAxel Bonnet, Jun 7, 2010
  2. 1/3 textconv: make the API publicAxel Bonnet, Jun 7, 2010
  3. 2/3 textconv: support for blameAxel Bonnet, Jun 7, 2010
  4. 3/3 t/t8006: test textconv support for blameAxel Bonnet, Jun 7, 2010
  5. Junio C HamanoJun 11, 2010
  6. Diane GasselinJun 14, 2010
  7. Junio C HamanoJun 11, 2010
  8. Jeff KingJun 12, 2010
  9. Junio C HamanoJun 14, 2010
  10. Clément PoulainJun 15, 2010
  11. Jeff KingJun 15, 2010
  12. bonnetaJun 15, 2010
  13. Matthieu MoyJun 15, 2010
  14. Junio C HamanoJun 15, 2010
  15. 2/3 textconv: support for blameAxel Bonnet, Jun 15, 2010
  16. Jeff KingJun 15, 2010
  17. bonnetaJun 15, 2010

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.