Re: [PATCH v2] git-compat-util: use gettimeofday(2) for time(2)
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Mar 21, 2023, 19:06 UTC
- Message-ID
- <ZBoAQFCWGhwIO963@nand.local>
- In-Reply-To
- <20230321182252.GJ3119834@coredump.intra.peff.net>
On Tue, Mar 21, 2023 at 02:22:52PM -0400, Jeff King wrote:
> The disadvantage is that it's longer to type, and that you have to > declare a timeval in the caller. So maybe it's a dumb idea.
I don't think it's a dumb idea per-se, but I think that being able to pass `time(NULL)` around without having to create a timeval and pass a pointer to *it* before then giving that timeval to some other function is a nice advantage.
So, yeah, we probably should just avoid calling time() altogether, but in practice I like the solution of redefining time() to do the right thing and implement it by calling gettimeofday().
...Which is a long way of saying that I agree with you that this approach looks good, and that I'd like to avoid putting time() in the list of banned functions.
Thanks, Taylor