[tz] localtime.c patch
Arthur David Olson
arthurdavidolson at gmail.com
Tue Oct 7 20:48:33 UTC 2014
Back in the 1980s (when this code had its origins), NULL pointers weren't
guaranteed to be all zeroes; having a static, otherwise unused structure
(which was guaranteed to be initialized correctly) for initialization
purposes was cheap portability insurance. (The insurance was taken out
consistently, both for uniformity and to avoid problems if a pointer was
added to a structure later.) Given updates to the C standard and waning
interest in supporting old systems, this insurance may well no longer be
needed.
Meanwhile, changing...
memset(sp->ttis, 0, sizeof(sp->ttis));
...to...
memset(sp->ttis, 0, sizeof sp->ttis);
...saves a character and is a reminder (to me, at least) that sizeof isn't
a function.
@dashdashado
On Tue, Oct 7, 2014 at 4:25 PM, Christos Zoulas <christos at zoulas.com> wrote:
> Minor nits.
>
> christos
>
> --- localtime.c.orig 2014-10-07 16:20:32.000000000 -0400
> +++ localtime.c 2014-10-07 16:22:47.000000000 -0400
> @@ -306,3 +306,3 @@
> register int stored;
> - register int nread;
> + register ssize_t nread;
> typedef union {
> @@ -934,3 +934,2 @@
> register bool load_ok;
> - static struct ttinfo zttinfo;
>
> @@ -1006,3 +1005,3 @@
> */
> - sp->ttis[0] = sp->ttis[1] = zttinfo;
> + memset(sp->ttis, 0, sizeof(sp->ttis));
> sp->ttis[0].tt_gmtoff = -dstoffset;
> @@ -1131,3 +1130,3 @@
> */
> - sp->ttis[0] = sp->ttis[1] = zttinfo;
> + memset(sp->ttis, 0, sizeof(sp->ttis));
> sp->ttis[0].tt_gmtoff = -stdoffset;
> @@ -1145,3 +1144,3 @@
> sp->timecnt = 0;
> - sp->ttis[0] = zttinfo;
> + memset(sp->ttis, 0, sizeof(sp->ttis));
> sp->ttis[0].tt_gmtoff = -stdoffset;
> @@ -2108,3 +2107,2 @@
>
> - sp = lclptr;
> i = sp->leapcnt;
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mm.icann.org/pipermail/tz/attachments/20141007/673c7f7e/attachment.htm>
More information about the tz
mailing list