Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/bin/sleep



I think it is easier and less error-prone to consistently cast time_t
to intmax_t instead of choosing how to cast based on knowing the range.

christos

> On Jan 26, 2019, at 9:59 PM, Robert Elz <kre%munnari.OZ.AU@localhost> wrote:
> 
>    Date:        Sat, 26 Jan 2019 21:00:45 -0500
>    From:        "Christos Zoulas" <christos%netbsd.org@localhost>
>    Message-ID:  <20190127020045.35A7DFB16%cvs.NetBSD.org@localhost>
> 
>  | cast to intmax_t instead of long, since time_t is "long long"
> 
> Some of  this is unnecessary, though not technically wrong, Martin's
> change was fine, and the same thing I would have done (was doing,
> but he got the commit processed first!)
> 
> The value being printed has already been range checked, it would
> actually be fine to print it as an int.  The same is true of another of
> the ones you changed (the 2nd warnx()).   That is, we don't need
> %jd to print values that we know are either < 2000, or < 100000.
> 
> The first of the 3 warnx's that were altered ought more correctly (usefully)
> be printed using %g as is done for the same value other places, I just
> had not had any reason to alter that one recently - (that contained the
> remnants of the original warnx() from the historic sleep.c which used
> (long) for all of these values).   %g produices more rational output for
> very large values than %(anything)d does, and it is only when we
> have a very large value that there's any difference between %ld and
> %jd (as long as the corresponding arg is the correct type, of course.)
> 
> kre
> 
> 



Home | Main Index | Thread Index | Old Index