From: Dan McGee Date: Tue, 19 May 2009 04:32:48 GMT Subject: Re: [PATCH] Fix type-punning issues 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 wrote: > Dan McGee 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. > > 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