Re: [PATCH] Fix type-punning issues
- From
Dan McGee <dpmcgee@gmail.com>
- Date
- May 19, 2009, 04:32 UTC
- Message-ID
- <449c10960905182132h2c1b38b4jd28721adaeb38484@mail.gmail.com>
- In-Reply-To
- <7vy6t292ix.fsf@alter.siamese.dyndns.org>
On Tue, May 12, 2009 at 2:57 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 8 quoted lines
> Dan McGee <dpmcgee@gmail.com> writes: > >> In these two places we are casting part of our unsigned char sha1 array into >> an unsigned int, which violates GCCs strict-aliasing rules (and probably >> other compilers). > > Yay. >
Show 7 quoted lines
> It might make more sense to have one canonical > > unsigned int hash_obj(const struct object *obj, unsigned int n) > > here, export it to object.h, and remove the one in decorate.c. > > Or am I missing something?
(argh: sorry Junio for sending the last reply to just you)
So due to me taking so long to resubmit, I see you committed a stripped-down version of my patch. I had a patch just like this (minus one newline diff), but it was in a series of 4 I will submit in just a second.
The three remaining patches implement the above suggestion of having one canonical "hash" function. However, the name changes to hash_char and takes a unsigned char pointer rather than a struct object pointer so we can use the same function for both insertion into the hashes as well as lookup.
Looking forward to any feedback.
-Dan