On Tue, Jun 15, 2010 at 11:29:57AM +0200, Clément Poulain wrote: > > 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. > 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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html