From: Paul Eggert <eggert@cs.ucla.edu>
To: libc-alpha@sourceware.org
Cc: Paul Eggert <eggert@cs.ucla.edu>
Subject: [PATCH 11/59] tzset no longer calls ftello
Date: Sat, 4 Jan 2025 21:56:46 -0800 [thread overview]
Message-ID: <20250105055750.1668721-12-eggert@cs.ucla.edu> (raw)
In-Reply-To: <01207110-bd60-46ae-9c08-fb39c2011067@cs.ucla.edu>
* time/tzfile.c (__tzfile_read): Compute file offset directly
rather than invoking ftello.
---
time/tzfile.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/time/tzfile.c b/time/tzfile.c
index 9d5f428f47..15d1890892 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -168,6 +168,7 @@ __tzfile_read (const char *file)
f = fopen (file, "rce");
if (f == NULL)
goto ret_free_transitions;
+ off_t f_offset = 0;
/* Get information about the file we are actually using. */
if (__fstat64_time64 (__fileno (f), &st) != 0)
@@ -190,6 +191,7 @@ __tzfile_read (const char *file)
|| memcmp (tzhead.tzh_magic, TZ_MAGIC, sizeof (tzhead.tzh_magic)) != 0)
goto lose;
+ f_offset += sizeof tzhead;
num_transitions = (size_t) decode (tzhead.tzh_timecnt);
num_types = (size_t) decode (tzhead.tzh_typecnt);
chars = (size_t) decode (tzhead.tzh_charcnt);
@@ -215,6 +217,7 @@ __tzfile_read (const char *file)
if (fseek (f, to_skip, SEEK_CUR) != 0)
goto lose;
+ f_offset += to_skip;
goto read_again;
}
@@ -223,7 +226,7 @@ __tzfile_read (const char *file)
size_t tzspec_len;
if (trans_width == 8)
{
- off_t rem = st.st_size - __ftello (f);
+ off_t rem = st.st_size - f_offset;
if (__builtin_expect (rem < 0
|| (size_t) rem < (num_transitions * (8 + 1)
+ num_types * 6
--
2.45.2
next prev parent reply other threads:[~2025-01-05 5:58 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-02 17:42 [PATCH v2 0/4] mktime tm_isdst compatibility improvements Florian Weimer
2025-01-02 17:42 ` [PATCH v2 1/4] time: Use __tz_convert in mktime implementation Florian Weimer
2025-01-02 17:42 ` [PATCH v2 2/4] time: Push tzset lock into callers of time functions Florian Weimer
2025-01-02 17:42 ` [PATCH v2 3/4] time: Do not perform forced DST adjustment for DST-less zones Florian Weimer
2025-01-02 17:42 ` [PATCH v2 4/4] time: Implement the glibc.time.mktime_dst_adjustment tunable Florian Weimer
2025-01-05 2:58 ` [PATCH v2 0/4] mktime tm_isdst compatibility improvements Paul Eggert
2025-01-05 5:56 ` [PATCH 00/59] time: sync mktime from Gnulib Paul Eggert
2025-01-06 14:30 ` Carlos O'Donell
2025-01-06 21:34 ` Joseph Myers
2025-01-06 21:43 ` Paul Eggert
2025-01-05 5:56 ` [PATCH 01/59] Split intprops.h into two Paul Eggert
2025-01-05 5:56 ` [PATCH 02/59] Support stdckdint.h internally if older GCC Paul Eggert
2025-01-05 5:56 ` [PATCH 03/59] Fix mishandling of default DST rule Paul Eggert
2025-01-05 5:56 ` [PATCH 04/59] Don't worry about !TZDEFAULT Paul Eggert
2025-01-05 5:56 ` [PATCH 05/59] Support static_assert in pre-C23 C Paul Eggert
2025-01-05 5:56 ` [PATCH 06/59] Sync mktime.c from Gnulib 2024-10-04 Paul Eggert
2025-01-05 5:56 ` [PATCH 07/59] Document mktime out-of-range + tm_isdst Paul Eggert
2025-01-05 8:03 ` Florian Weimer
2025-01-05 14:03 ` Paul Eggert
2025-01-05 5:56 ` [PATCH 08/59] Push tzset lock into callers of time functions Paul Eggert
2025-01-05 5:56 ` [PATCH 09/59] Omit parse_offset unnecessary *tz == '\0' Paul Eggert
2025-01-05 5:56 ` [PATCH 10/59] Don’t assume TZif bloat is likely Paul Eggert
2025-01-05 5:56 ` Paul Eggert [this message]
2025-01-05 5:56 ` [PATCH 12/59] Check TZif files more carefully Paul Eggert
2025-01-05 5:56 ` [PATCH 13/59] Remove alignment assumption from __tzfile_read Paul Eggert
2025-01-05 5:56 ` [PATCH 14/59] Treat oddball UTC offset strings as zero Paul Eggert
2025-01-05 5:56 ` [PATCH 15/59] Simplify __tz_compute Paul Eggert
2025-01-05 5:56 ` [PATCH 16/59] Improve performance in 2 BC Paul Eggert
2025-01-05 5:56 ` [PATCH 17/59] Don’t mishandle years < 1970 in compute_change Paul Eggert
2025-01-05 5:56 ` [PATCH 18/59] Match RFC 9636 names Paul Eggert
2025-01-05 5:56 ` [PATCH 19/59] Trivial tzset_internal speedup Paul Eggert
2025-01-05 5:56 ` [PATCH 20/59] Fix obscure bug when stdoffset == dstoffset Paul Eggert
2025-01-05 5:56 ` [PATCH 21/59] Document assumption that NO_DST == 0 Paul Eggert
2025-01-05 5:56 ` [PATCH 22/59] __use_tzfile is boolean Paul Eggert
2025-01-05 5:56 ` [PATCH 23/59] Minor tzfile.c clarity improvements Paul Eggert
2025-01-05 5:56 ` [PATCH 24/59] Stop using zic's -y option Paul Eggert
2025-01-05 5:57 ` [PATCH 25/59] Fix mishandling of default DST rule Paul Eggert
2025-01-05 5:57 ` [PATCH 26/59] Simplify treatment of missing and empty TZ Paul Eggert
2025-01-05 5:57 ` [PATCH 27/59] TZ="" always means UTC sans leap seconds Paul Eggert
2025-01-05 5:57 ` [PATCH 28/59] Prefer "UTC" for UTC Paul Eggert
2025-01-05 5:57 ` [PATCH 29/59] Simplify setting tz_rules to UTC Paul Eggert
2025-01-05 5:57 ` [PATCH 30/59] Update tzname etc. even if TZ is unchanged Paul Eggert
2025-01-05 5:57 ` [PATCH 31/59] "POSIX TZ" -> "proleptic TZ" Paul Eggert
2025-01-05 5:57 ` [PATCH 32/59] Reject invalid TZ strings in TZif files Paul Eggert
2025-01-05 5:57 ` [PATCH 33/59] Reject TZif files containing '\0' in TZ string Paul Eggert
2025-01-05 5:57 ` [PATCH 34/59] mktime should not consult 'daylight' Paul Eggert
2025-01-05 5:57 ` [PATCH 35/59] Remove __use_tzfile Paul Eggert
2025-01-05 5:57 ` [PATCH 36/59] Remove arbitrary limit on TZ, TZDIR lengths Paul Eggert
2025-01-05 5:57 ` [PATCH 37/59] Tighten setuid TZif file name check Paul Eggert
2025-01-05 5:57 ` [PATCH 38/59] Avoid a malloc in __tzfile_read Paul Eggert
2025-01-05 5:57 ` [PATCH 39/59] Free earlier " Paul Eggert
2025-01-05 5:57 ` [PATCH 40/59] Improve __tzfile_read TZ="" comment Paul Eggert
2025-01-05 5:57 ` [PATCH 41/59] Refactor enum tz_rule_type Paul Eggert
2025-01-05 5:57 ` [PATCH 42/59] __offtime now returns struct tm * Paul Eggert
2025-01-05 5:57 ` [PATCH 43/59] Fix overflow checking in offtime Paul Eggert
2025-01-05 5:57 ` [PATCH 44/59] Handle TZif time type 0 correctly Paul Eggert
2025-01-05 5:57 ` [PATCH 45/59] Remove invalid tzset tests from tst-bz29951.c Paul Eggert
2025-01-05 5:57 ` [PATCH 46/59] tzset, not localtime, now parses TZif TZ spec Paul Eggert
2025-01-05 5:57 ` [PATCH 47/59] Minor compute_change widening tweak Paul Eggert
2025-01-05 5:57 ` [PATCH 48/59] Minor SECSPERDAY " Paul Eggert
2025-01-05 5:57 ` [PATCH 49/59] Remove leap-second goto from __tzfile_compute Paul Eggert
2025-01-05 5:57 ` [PATCH 50/59] Remove use_last label " Paul Eggert
2025-01-05 5:57 ` [PATCH 51/59] Refactor ‘if’ in __tzfile_compute Paul Eggert
2025-01-05 5:57 ` [PATCH 52/59] Refactor localtime " Paul Eggert
2025-01-05 5:57 ` [PATCH 53/59] Refactor post-transition-table ‘if’ Paul Eggert
2025-01-05 5:57 ` [PATCH 54/59] Refactor __tzfile_compute to avoid two gotos Paul Eggert
2025-01-05 5:57 ` [PATCH 55/59] Refactor __tzfile_compute index local Paul Eggert
2025-01-05 5:57 ` [PATCH 56/59] mktime: prefer bool to int Paul Eggert
2025-01-05 5:57 ` [PATCH 57/59] mktime: port __mktime64 locking to Gnulib Paul Eggert
2025-01-05 5:57 ` [PATCH 58/59] mktime: improve tm_isdst heuristic Paul Eggert
2025-01-05 5:57 ` [PATCH 59/59] time: test DST adjustment for DST-less zones Paul Eggert
2025-01-07 8:59 ` [PATCH v2 0/4] mktime tm_isdst compatibility improvements Florian Weimer
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=20250105055750.1668721-12-eggert@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=libc-alpha@sourceware.org \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).