All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jason Hatton <jhatton@globalfinishing.com>
Cc: Jeff King <peff@peff.net>,
	 "brian m. carlson" <sandals@crustytoothpaste.net>,
	 "git@vger.kernel.org" <git@vger.kernel.org>,
	 Taylor Blau <me@ttaylorr.com>
Subject: Re: [PATCH v2 2/2] Prevent git from rehashing 4GiB files
Date: Tue, 17 Oct 2023 10:02:57 -0700	[thread overview]
Message-ID: <xmqqedhtji66.fsf@gitster.g> (raw)
In-Reply-To: <MW5PR16MB50791EDD3D006EFBE8DBBCB3AFD6A@MW5PR16MB5079.namprd16.prod.outlook.com> (Jason Hatton's message of "Tue, 17 Oct 2023 14:49:09 +0000")

Jason Hatton <jhatton@globalfinishing.com> writes:

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

  reply	other threads:[~2023-10-17 17:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 16:09 [PATCH v2 0/2] Prevent re-reading 4 GiB files on every status brian m. carlson
2023-10-12 16:09 ` [PATCH v2 1/2] t: add a test helper to truncate files brian m. carlson
2023-10-12 17:49   ` Eric Sunshine
2023-10-13 20:23     ` brian m. carlson
2023-10-12 22:52   ` Junio C Hamano
2023-10-13 20:18     ` brian m. carlson
2023-10-13 20:32       ` Junio C Hamano
2023-10-16 23:53   ` Jeff King
2023-10-12 16:09 ` [PATCH v2 2/2] Prevent git from rehashing 4GiB files brian m. carlson
2023-10-12 17:58   ` Junio C Hamano
2023-10-12 21:58     ` brian m. carlson
2023-10-12 22:11       ` Junio C Hamano
2023-10-17  0:00   ` Jeff King
2023-10-17 14:49     ` Jason Hatton
2023-10-17 17:02       ` Junio C Hamano [this message]
2023-10-18  0:42     ` brian m. carlson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqedhtji66.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jhatton@globalfinishing.com \
    --cc=me@ttaylorr.com \
    --cc=peff@peff.net \
    --cc=sandals@crustytoothpaste.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.