git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] read-cache: use time_t instead of unsigned long

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 12, 2018, 15:03 UTC
Message-ID
<xmqq7ehi1gpb.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<nycvar.QRO.7.76.6.1811121554060.39@tvgsbejvaqbjf.bet>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 8 quoted lines
>> 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?
>
> Riiiight. From the patch, I had assumed that the return type of
> `approxidate()` is `time_t`, but it is `timestamp_t`.

Yes, but if we dig a bit deeper, it turns out that the return value of this function is used at only one place, to be compared with the .st_mtime field.

So for this change to truly be consisent, not just the function needs to return timestamp_t, but also its sole caller needs to check if its return value exceeds the maximum span that is expressible with the platform's time_t (and if so, treat the expiration to be "infinity- never expire"), or something like that.

Previous: Johannes SchindelinNext: Carlo Marcelo Arenas Belón
Message 7 of 12 in “avoid unsigned long for timestamps”
  1. 0/2 avoid unsigned long for timestampsCarlo Marcelo Arenas Belón, Nov 12, 2018
  2. 1/2 builtin/commit: use timestamp_t in parse_force_dateCarlo Marcelo Arenas Belón, Nov 12, 2018
  3. 2/2 read-cache: use time_t instead of unsigned longCarlo Marcelo Arenas Belón, Nov 12, 2018
  4. Eric SunshineNov 12, 2018
  5. Junio C HamanoNov 12, 2018
  6. Johannes SchindelinNov 12, 2018
  7. Junio C HamanoNov 12, 2018
  8. 2/2 read-cache: use time_t instead of unsigned longCarlo Marcelo Arenas Belón, Nov 13, 2018
  9. Johannes SchindelinNov 13, 2018
  10. Carlo ArenasNov 13, 2018
  11. Junio C HamanoNov 13, 2018
  12. Johannes SchindelinNov 12, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.