[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gnulib support for st_birthtime (second revision of patch)
From: |
Paul Eggert |
Subject: |
Re: gnulib support for st_birthtime (second revision of patch) |
Date: |
Thu, 29 Mar 2007 13:20:09 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
"James Youngman" <address@hidden> writes:
> On 3/27/07, Paul Eggert <address@hidden> wrote:
>> - /* Birth time not supported. */
>> - pts->tv_sec = 0;
>> - pts->tv_nsec = 0;
>> - return 0; /* result is not valid */
>> + /* Birth time is not supported. Set tv_sec to avoid undefined behavior.
>> */
>> + t.tv_sec = -1;
>> + t.tv_nsec = -1;
>
> This is an implicit change from what *BSD does in this situation; it
> normally tries to return (time_t)0 in tv_sec.
>
> To be honest, I don't like the convention of returning ((time_t)0)
> myself, since it's a valid timestamp. Using ((time_t)-1) seems more
> sensible to me, by analogy with the result of time(2).
>
> Was the change deliberate?
Yes. The key here is that tv_nsec < 0 indicates an error, so the
value of tv_sec is irrelevant.
We have to set tv_sec to something to avoid undefined behavior. -1 is
cheap since it's already in a register, and I suppose using -1 might
help track down bugs in buggy callers.
However, (time_t) -1 is also a valid time_t value, so callers
shouldn't use tv_sec==-1 to detect the error case. They should use
tv_nsec<0.
- gnulib support for st_birthtime (second revision of patch), James Youngman, 2007/03/27
- Re: gnulib support for st_birthtime (second revision of patch), Bruno Haible, 2007/03/27
- Re: gnulib support for st_birthtime (second revision of patch), James Youngman, 2007/03/27
- Re: gnulib support for st_birthtime (second revision of patch), Bruno Haible, 2007/03/27
- Re: gnulib support for st_birthtime (second revision of patch), Eric Blake, 2007/03/27
- Re: gnulib support for st_birthtime (second revision of patch), Paul Eggert, 2007/03/27
- Re: gnulib support for st_birthtime (second revision of patch), Eric Blake, 2007/03/27
- Re: gnulib support for st_birthtime (second revision of patch), James Youngman, 2007/03/28
- Re: gnulib support for st_birthtime (second revision of patch),
Paul Eggert <=
- Re: gnulib support for st_birthtime (second revision of patch), Bruno Haible, 2007/03/29
- Re: gnulib support for st_birthtime (second revision of patch), James Youngman, 2007/03/29
- Re: gnulib support for st_birthtime (second revision of patch), Bruno Haible, 2007/03/31
- Re: gnulib support for st_birthtime (second revision of patch), Bruno Haible, 2007/03/29
Re: gnulib support for st_birthtime (second revision of patch), Jim Meyering, 2007/03/27