git: d63ffdd1ef63 - main - tzcode: Fix time zone change detection.
Date: Fri, 18 Jul 2025 17:50:21 UTC
The branch main has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=d63ffdd1ef6368407b35d415237b95cc739d8073
commit d63ffdd1ef6368407b35d415237b95cc739d8073
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2025-07-18 17:48:59 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2025-07-18 17:49:34 +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
---
contrib/tzcode/localtime.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/contrib/tzcode/localtime.c b/contrib/tzcode/localtime.c
index f5814a43da54..69b5f0183e2c 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,11 @@ 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;
}
}
fid = _open(name, O_RDONLY | O_BINARY);