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

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

From
Jeff King <peff@peff.net>
Date
Jun 15, 2010, 09:54 UTC
Message-ID
<20100615095452.GA32624@sigill.intra.peff.net>
In-Reply-To
<0091febb4a3832a6680a0fbc2209f841@ensimag.fr>
On Tue, Jun 15, 2010 at 11:29:57AM +0200, Clément Poulain wrote:
Show 10 quoted lines
> > The same issue exists in Clément's patch to builtin/cat-file.c.
> 
> We did this way because we found a similar cast in prep_temp_blob(),
> diff.c:
> 
> 	if (convert_to_working_tree(path,
> 			(const char *)blob, (size_t)size, &buf)) {
> 
> where size is an unsigned long.
> Is it the same issue ? Or is it different because it's not a pointer cast?

Right. The compiler will handle conversion between integer types during assignment itself, converting representations as necessary (in fact, that cast looks useless to me, as implicit conversions are allowed in C). The only problem is dereferencing a pointer to X as something other than X.

Show 5 quoted lines
> Otherwise, we thought of reversing the conversion. That is to say, instead
> of casting "long *" in "size_t *" when calling textconv_object(), is it
> better to cast size_t in "unsigned long" in textconv_object():
> 
> 	*buf_size = (unsigned long) fill_textconv(textconv, df, buf); ?

You shouldn't even have to cast there, for the same reason as above. That is why I wrote fill_textconv to return the size parameter, rather than writing to a passed-in pointer. It avoids the annoying size_t / unsigned long casting caused by different usage (in an ideal world, all of our sizes would be the same type, but the strbuf and diff code obviously differ).

-Peff
Previous: Clément PoulainNext: bonneta
Message 11 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.