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

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

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Jun 15, 2010, 10:51 UTC
Message-ID
<vpqbpbc4lh3.fsf@bauges.imag.fr>
In-Reply-To
<192517e06785fed4fa799bee9a11ae28@ensimag.fr>
bonneta <bonneta@ensimag.fr> writes:
Show 6 quoted lines
> 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?

I don't think it fixes the problem. You're assuming sizeof(unsigned long) == sizeof(size_t), otherwise, textconv_object will write the incorrect number of bytes at the given adress.

If you have to use this pass-by-adress, you want
size_t buf_len; /* textconv_object needs a last parameter of type
                   (size_t *) */
textconv_object(..., &buf_len); /* <-- no cast here */
buf.len = buf_len; /* This is a cast, but not a pointer cast. The
                      compiler will do the actual conversion if
                      needed (while pointer casts are just a matter of
                      typing, the generate no code). */
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: bonnetaNext: Junio C Hamano
Message 13 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.