git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: Eric Wong <e@80x24.org>, Taylor Blau <me@ttaylorr.com>,
	git@vger.kernel.org
Subject: Re: [PATCH v2] git-compat-util: use gettimeofday(2) for time(2)
Date: Tue, 21 Mar 2023 09:20:09 -0700	[thread overview]
Message-ID: <xmqq4jqekreu.fsf@gitster.g> (raw)
In-Reply-To: <f78fd970-cce5-0a38-5ada-94ccb5bce592@cs.ucla.edu> (Paul Eggert's message of "Mon, 20 Mar 2023 16:21:40 -0700")

Paul Eggert <eggert@cs.ucla.edu> writes:

> Thanks, this looks good. As a matter of fact it almost precisely
> matches what I was about to email you. The only significant difference
> is that yours has "#define time(x) git_time(x)" whereas mine had
> "#define time git_time". Since Git never takes the address of 'time'
> the two macro definitions should have equivalent effects when used in
> Git.

That is a valid concern.  Writing &time would not be caught by
compilers, and you would not notice such a mistake until you run "nm
-ug" on the result.

On the other hand, straight token replacement will risk renaming
variables and structure members, and I was not sure if we have such
use of the identifier "time".  As long as people do not use "time"
and "git_time" at the same time as such identifiers, that would not
be an issue (except for perhaps expecting to see them in debuggers).
Writing "git_time" and "time" at the same time for identifiers not
related to the time(2) function would not be caught by compilers,
either, but it feels much less likely mistake we would make in the
future, so let me drop (x) from the macro.

Thanks.



  reply	other threads:[~2023-03-21 16:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-19  6:43 [PATCH 0/2] use gettimeofday for current time Paul Eggert
2023-03-19  6:43 ` [PATCH 1/2] git-compat-util: time_now " Paul Eggert
2023-03-19  6:43 ` [PATCH 2/2] git-compat-util: use gettimeofday " Paul Eggert
2023-03-19 19:34   ` Eric Wong
2023-03-20 16:33     ` Junio C Hamano
2023-03-20 17:01       ` Junio C Hamano
2023-03-20 19:00         ` Paul Eggert
2023-03-20 19:40           ` Junio C Hamano
2023-03-20 20:36             ` Taylor Blau
2023-03-20 20:35       ` Taylor Blau
2023-03-20 23:05 ` [PATCH v2] git-compat-util: use gettimeofday(2) for time(2) Junio C Hamano
2023-03-20 23:21   ` Paul Eggert
2023-03-21 16:20     ` Junio C Hamano [this message]
2023-03-21 17:44   ` Konstantin Khomoutov
2023-03-21 18:22     ` Junio C Hamano
2023-03-21 18:22   ` Jeff King
2023-03-21 19:06     ` Taylor Blau
2023-03-21 20:04     ` Junio C Hamano
2023-03-22 17:11       ` Jeff King

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=xmqq4jqekreu.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=e@80x24.org \
    --cc=eggert@cs.ucla.edu \
    --cc=git@vger.kernel.org \
    --cc=me@ttaylorr.com \
    /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).