Re: [PATCH v2 2/2] Prevent git from rehashing 4GiB files
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 17, 2023, 17:02 UTC
- Message-ID
- <xmqqedhtji66.fsf@gitster.g>
- In-Reply-To
- <MW5PR16MB50791EDD3D006EFBE8DBBCB3AFD6A@MW5PR16MB5079.namprd16.prod.outlook.com>
Jason Hatton <jhatton@globalfinishing.com> writes:
Show 17 quoted lines
> We could probably write the below to do the same thing.
>
> void fill_stat_data(struct stat_data *sd, struct stat *st)
> {
> sd->sd_ctime.sec = (unsigned int)st->st_ctime;
> sd->sd_mtime.sec = (unsigned int)st->st_mtime;
> sd->sd_ctime.nsec = ST_CTIME_NSEC(*st);
> sd->sd_mtime.nsec = ST_MTIME_NSEC(*st);
> sd->sd_dev = st->st_dev;
> sd->sd_ino = st->st_ino;
> sd->sd_uid = st->st_uid;
> sd->sd_gid = st->st_gid;
> sd->sd_size = st->st_size;
> + if (sd->sd_size == 0 && st->st_size!= 0) {
> + sd->sd_size = 1;
> + }
> }The above is a fairly straight-forward inlining (except that it does explicit comparisons with zero) of the helper function the version of patch under discussion added, and uses 1 instead of (1<<31) as an arbigrary nonzero number that can be used to work around the issue.
So I agree with you that it would do the same thing. I am not surprised if it also gets scolded by Coverity the same way, though.