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/