From: Jeff King <peff@peff.net>
To: "Clément Poulain" <clement.poulain@ensimag.imag.fr>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH v2 2/3] textconv: support for blame
Date: Tue, 15 Jun 2010 05:54:53 -0400 [thread overview]
Message-ID: <20100615095452.GA32624@sigill.intra.peff.net> (raw)
In-Reply-To: <0091febb4a3832a6680a0fbc2209f841@ensimag.fr>
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
next prev parent reply other threads:[~2010-06-15 9:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-07 14:41 [PATCH v2 0/3] textconv support for blame Axel Bonnet
2010-06-07 15:23 ` [PATCH v2 1/3] textconv: make the API public Axel Bonnet
2010-06-07 15:23 ` [PATCH v2 2/3] textconv: support for blame Axel Bonnet
2010-06-07 15:23 ` [PATCH v2 3/3] t/t8006: test textconv " Axel Bonnet
2010-06-11 23:52 ` Junio C Hamano
2010-06-14 7:52 ` Diane Gasselin
2010-06-11 23:52 ` [PATCH v2 2/3] textconv: " Junio C Hamano
2010-06-12 4:11 ` Jeff King
2010-06-14 20:40 ` Junio C Hamano
2010-06-15 9:29 ` Clément Poulain
2010-06-15 9:54 ` Jeff King [this message]
2010-06-15 10:32 ` bonneta
2010-06-15 10:51 ` Matthieu Moy
[not found] ` <aad13a73928536f87879ef7284d6cc75@ensimag.fr>
2010-06-15 11:07 ` Jeff King
2010-06-15 12:13 ` bonneta
2010-06-15 15:00 ` Junio C Hamano
2010-06-15 13:58 ` Axel Bonnet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100615095452.GA32624@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=clement.poulain@ensimag.imag.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).