]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
time: Use int, not long int, for internal GMT offsets
authorFlorian Weimer <fweimer@redhat.com>
Sun, 3 Feb 2019 08:55:41 +0000 (09:55 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Sun, 3 Feb 2019 08:55:41 +0000 (09:55 +0100)
The GMT offset can be outside the range of a 16-bit int type, which
is presumably the reason why long int was used in struct tm.  We
cannot change struct tm, but we can change the internal type for
the offset.

ChangeLog
include/time.h
time/tzfile.c
time/tzset.c

index 8f311cc071fc590b8ff99f02a2768b99d3eb7248..628aaef05fb8a3685d50bc726f6cf42ad06c4c3b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2019-02-03  Florian Weimer  <fweimer@redhat.com>
+
+       * include/time.h (__tzfile_default): Use int, not long int, for
+       the GMT offsets.
+       * time/tzfile.c (struct ttinfo): Change type of the offset member
+       to int.
+       (__tzfile_read): Remove useless cast.
+       (__tzfile_default): Adjust prototype.
+       * time/tzset.c (tz_rule): Change type of the offset member to int.
+       (parse_offset): Change the type of the sign variable to int.
+
 2019-02-03  Florian Weimer  <fweimer@redhat.com>
 
        [BZ #24153]
index f935e9dd3e07daa4d49f60f6318a9a80eb0235a2..61dd9e180bb94d5c65ba1cb0dd9704b97f798c9e 100644 (file)
@@ -43,7 +43,7 @@ extern void __tzfile_compute (__time64_t timer, int use_localtime,
                              long int *leap_correct, int *leap_hit,
                              struct tm *tp) attribute_hidden;
 extern void __tzfile_default (const char *std, const char *dst,
-                             long int stdoff, long int dstoff)
+                             int stdoff, int dstoff)
   attribute_hidden;
 extern void __tzset_parse_tz (const char *tz) attribute_hidden;
 extern void __tz_compute (__time64_t timer, struct tm *tm, int use_localtime)
index 24440a6a9c24c8337ddc9c988415d0e034cdc2cb..a07e7c503723a1b529e1ed06b99d08dfd5baf622 100644 (file)
@@ -35,7 +35,7 @@ static time_t tzfile_mtime;
 
 struct ttinfo
   {
-    long int offset;           /* Seconds east of GMT.  */
+    int offset;                        /* Seconds east of GMT.  */
     unsigned char isdst;       /* Used to set tm_isdst.  */
     unsigned char idx;         /* Index into `zone_names'.  */
     unsigned char isstd;       /* Transition times are in standard time.  */
@@ -345,7 +345,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
        /* Bogus index in data file.  */
        goto lose;
       types[i].idx = c;
-      types[i].offset = (long int) decode (x);
+      types[i].offset = decode (x);
     }
 
   if (__glibc_unlikely (__fread_unlocked (zone_names, 1, chars, f) != chars))
@@ -491,7 +491,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
 
 void
 __tzfile_default (const char *std, const char *dst,
-                 long int stdoff, long int dstoff)
+                 int stdoff, int dstoff)
 {
   size_t stdlen = strlen (std) + 1;
   size_t dstlen = strlen (dst) + 1;
index d026674d116b6e881c98e055ef1f80f3c5da4a01..307eb651ad98603bff48f2ca249740e810b05181 100644 (file)
@@ -50,7 +50,7 @@ typedef struct
     unsigned short int m, n, d;        /* Month, week, day.  */
     int secs;                  /* Time of day.  */
 
-    long int offset;           /* Seconds east of GMT (west if < 0).  */
+    int offset;                        /* Seconds east of GMT (west if < 0).  */
 
     /* We cache the computed time of change for a
        given year so we don't have to recompute it.  */
@@ -193,11 +193,11 @@ parse_offset (const char **tzp, int whichrule)
       && (*tz == '\0' || (*tz != '+' && *tz != '-' && !isdigit (*tz))))
     return false;
 
-  long sign;
+  int sign;
   if (*tz == '-' || *tz == '+')
-    sign = *tz++ == '-' ? 1L : -1L;
+    sign = *tz++ == '-' ? 1 : -1;
   else
-    sign = -1L;
+    sign = -1;
   *tzp = tz;
 
   unsigned short int hh;