The branch stable/13 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=b86c6997047e6caee085b05dcc864f7878db3b69
commit b86c6997047e6caee085b05dcc864f7878db3b69 Author: Dag-Erling Smørgrav <d...@freebsd.org> AuthorDate: 2025-07-18 17:48:59 +0000 Commit: Dag-Erling Smørgrav <d...@freebsd.org> CommitDate: 2025-07-24 13:02:13 +0000 tzcode: Fix time zone change detection. Prior to the 2022g import, tzloadbody() returned -1 on error. Now it returns an errno code. When I updated the time zone change detection logic to match, I improperly returned errno in all cases, which means that if the time zone file has not changed since we last loaded it, tzloadbody() returns a random errno value instead of 0. Fixes: bc42155199b5 MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D51405 (cherry picked from commit d63ffdd1ef6368407b35d415237b95cc739d8073) tzcode: Add an explicit "the timezone file has changed" case This is required for the WITHOUT_DETECT_TZ_CHANGES case, since there the value being tested is a numeric literal. Fixes: d63ffdd1ef63 ("tzcode: Fix time zone change detection.") (cherry picked from commit 0bf113e9041fe20e8c671fe6b2cca8612dc77b77) --- contrib/tzcode/localtime.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/contrib/tzcode/localtime.c b/contrib/tzcode/localtime.c index f5814a43da54..bdec08e4abae 100644 --- a/contrib/tzcode/localtime.c +++ b/contrib/tzcode/localtime.c @@ -408,10 +408,8 @@ change_in_tz(const char *name) static char old_name[PATH_MAX]; static struct stat old_sb; struct stat sb; - int error; - error = stat(name, &sb); - if (error != 0) + if (stat(name, &sb) != 0) return -1; if (strcmp(name, old_name) != 0) { @@ -510,13 +508,13 @@ tzloadbody(char const *name, struct state *sp, bool doextend, * 'doextend' to ignore TZDEFRULES; the change_in_tz() * function can only keep state for a single file. */ - int ret = change_in_tz(name); - if (ret <= 0) { - /* - * Returns an errno value if there was an error, - * and 0 if the timezone had not changed. - */ + switch (change_in_tz(name)) { + case -1: return errno; + case 0: + return 0; + case 1: + break; } } fid = _open(name, O_RDONLY | O_BINARY);