From: Junio C Hamano <gitster@pobox.com>
To: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>
Cc: git@vger.kernel.org, christian.couder@gmail.com,
johannes.schindelin@gmx.de, peff@peff.net
Subject: Re: [PATCH 2/2] read-cache: use time_t instead of unsigned long
Date: Mon, 12 Nov 2018 19:53:11 +0900 [thread overview]
Message-ID: <xmqqftw61sa0.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20181112084031.11769-3-carenas@gmail.com> ("Carlo Marcelo Arenas Belón"'s message of "Mon, 12 Nov 2018 00:40:31 -0800")
Carlo Marcelo Arenas Belón <carenas@gmail.com> writes:
> b968372279 ("read-cache: unlink old sharedindex files", 2017-03-06)
> introduced get_shared_index_expire_date using unsigned long to track
> the modification times of a shared index.
>
> dddbad728c ("timestamp_t: a new data type for timestamps", 2017-04-26)
> shows why that might problematic so move to time_t instead.
>
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> ---
> read-cache.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/read-cache.c b/read-cache.c
> index 7b1354d759..5525d8e679 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -2625,9 +2625,9 @@ static int write_split_index(struct index_state *istate,
>
> static const char *shared_index_expire = "2.weeks.ago";
>
> -static unsigned long get_shared_index_expire_date(void)
> +static time_t get_shared_index_expire_date(void)
> {
> - static unsigned long shared_index_expire_date;
> + static time_t shared_index_expire_date;
> static int shared_index_expire_date_prepared;
>
> if (!shared_index_expire_date_prepared) {
After this line, the post-context reads like this:
git_config_get_expiry("splitindex.sharedindexexpire",
&shared_index_expire);
shared_index_expire_date = approxidate(shared_index_expire);
shared_index_expire_date_prepared = 1;
}
return shared_index_expire_date;
Given that the function returns the value obtained from
approxidate(), which is approxidate_careful() in disguise, time_t is
not as appropriate as timestamp_t, no?
IOW, what if time_t were narrower than timestamp_t?
> @@ -2643,7 +2643,7 @@ static unsigned long get_shared_index_expire_date(void)
> static int should_delete_shared_index(const char *shared_index_path)
> {
> struct stat st;
> - unsigned long expiration;
> + time_t expiration;
>
> /* Check timestamp */
> expiration = get_shared_index_expire_date();
next prev parent reply other threads:[~2018-11-12 10:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-12 8:40 [PATCH 0/2] avoid unsigned long for timestamps Carlo Marcelo Arenas Belón
2018-11-12 8:40 ` [PATCH 1/2] builtin/commit: use timestamp_t in parse_force_date Carlo Marcelo Arenas Belón
2018-11-12 8:40 ` [PATCH 2/2] read-cache: use time_t instead of unsigned long Carlo Marcelo Arenas Belón
2018-11-12 8:42 ` Eric Sunshine
2018-11-12 10:53 ` Junio C Hamano [this message]
2018-11-12 14:54 ` Johannes Schindelin
2018-11-12 15:03 ` Junio C Hamano
2018-11-13 7:40 ` Carlo Marcelo Arenas Belón
2018-11-13 8:49 ` Johannes Schindelin
2018-11-13 9:10 ` Carlo Arenas
2018-11-13 9:43 ` Junio C Hamano
2018-11-12 12:06 ` [PATCH 0/2] avoid unsigned long for timestamps Johannes Schindelin
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=xmqqftw61sa0.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=carenas@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
--cc=peff@peff.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).