Re: [PATCH] git-diff: fix combined diff

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
-
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

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]