Git development
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, junkio@cox.net
Subject: Re: [PATCH] git-diff: fix combined diff
Date: Fri, 23 Feb 2007 00:34:28 -0500	[thread overview]
Message-ID: <20070223053428.GA13301@coredump.intra.peff.net> (raw)
In-Reply-To: <Pine.LNX.4.63.0702230517480.22628@wbgn013.biozentrum.uni-wuerzburg.de>

On Fri, Feb 23, 2007 at 05:20:32AM +0100, Johannes Schindelin wrote:

> With "const unsigned (*parent)[20]", "parent + 1" is not the
> same as "&parent[1]"...

Actually, they _are_ the same (the C standard definition of A[B] is *(A+B)).
The problem is the operator precedence of the cast:

> -		hashcpy((unsigned char*)parent + i, ent[ents - 1 - i].item->sha1);

which translates to "cast parent to an unsigned char pointer, and then
add i * sizeof(unsigned char) to it".

Your fix works because [] binds more tightly, fixing the precedence
problem. You could also do this:
  hashcpy((unsigned char*)(parent + i), ...

-Peff

  parent reply	other threads:[~2007-02-23  5:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-23  4:20 [PATCH] git-diff: fix combined diff Johannes Schindelin
2007-02-23  5:22 ` Junio C Hamano
2007-02-23  6:09   ` Junio C Hamano
2007-02-23  5:34 ` Jeff King [this message]
2007-02-23 11:19   ` Johannes Schindelin

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=20070223053428.GA13301@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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