Re: [PATCH 4/6] Convert struct name_entry to use struct object_id.

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

 



"brian m. carlson" <sandals@xxxxxxxxxxxxxxxxxxxx> writes:

> On Tue, Apr 19, 2016 at 04:02:22PM -0700, Junio C Hamano wrote:
>> "brian m. carlson" <sandals@xxxxxxxxxxxxxxxxxxxx> writes:
>> 
>> > @@ -314,7 +314,7 @@ static int threeway_callback(int n, unsigned long mask, unsigned long dirmask, s
>> >  	}
>> >  
>> >  	if (same_entry(entry+0, entry+1)) {
>> > -		if (entry[2].sha1 && !S_ISDIR(entry[2].mode)) {
>> > +		if (entry[2].oid->hash && !S_ISDIR(entry[2].mode)) {
>> 
>> Thanks for a warning in the cover letter.
>> 
>> "if (entry[2].oid && !S_ISDIR(entry[2].mode)" would be a faithful
>> conversion, wouldn't it?
>
> Yes, I think that would be a better conversion.  I'll reroll after
> waiting for further comments.

Thanks.  A simple general rule to follow is that anything that
assumed entry.sha1 is non-NULL should become entry.oid->hash, while
anyting that checked if entry.sha1 is NULL or not should become a
check on entry.oid, I think.  Even though offsetof(oid.hash) might
happen to be zero, compiler writers are crazy and "optimize" the
above entry[2].oid->hash saying "you are dereerencing into the hash
field without first checking if oid pointer is NULL, so we'd assume
that you know oid is not NULL here--which makes this always true so
we won't even do any check and only check entry[2].mode"..

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