From: Theo Buehler Subject: time.h: const correct tm_zone To: tech@openbsd.org Date: Tue, 18 Nov 2025 09:32:21 +0100 POSIX.1-2024 standardized struct tm's tm_zone as a const char *: https://austingroupbugs.net/view.php?id=1533 Avoid casting away const and fix some warnings introduced in strptime.c r1.32 when moving gmt[] and utc[] to rodata: /usr/src/lib/libc/time/strptime.c:423:17: warning: assigning to 'char *' from 'const char[4]' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] 423 | tm->tm_zone = gmt; | ^ ~~~ This diff went through an amd64 bulk with no fallout. Index: include/time.h =================================================================== RCS file: /cvs/src/include/time.h,v diff -u -p -r1.32 time.h --- include/time.h 25 Oct 2022 16:30:30 -0000 1.32 +++ include/time.h 15 Nov 2025 16:50:37 -0000 @@ -106,7 +106,7 @@ struct tm { int tm_yday; /* days since January 1 [0-365] */ int tm_isdst; /* Daylight Saving Time flag */ long tm_gmtoff; /* offset from UTC in seconds */ - char *tm_zone; /* timezone abbreviation */ + const char *tm_zone; /* timezone abbreviation */ }; __BEGIN_DECLS Index: lib/libc/time/ctime.3 =================================================================== RCS file: /cvs/src/lib/libc/time/ctime.3,v diff -u -p -r1.49 ctime.3 --- lib/libc/time/ctime.3 23 Jun 2025 13:53:11 -0000 1.49 +++ lib/libc/time/ctime.3 15 Nov 2025 20:21:39 -0000 @@ -241,7 +241,7 @@ includes the following fields: int tm_yday; /* day of year (0 \- 365) */ int tm_isdst; /* is summer time in effect? */ long tm_gmtoff; /* offset from UT in seconds */ - char *tm_zone; /* abbreviation of timezone name */ + const char *tm_zone; /* abbreviation of timezone name */ .Ed .Pp The Index: lib/libc/time/localtime.c =================================================================== RCS file: /cvs/src/lib/libc/time/localtime.c,v diff -u -p -r1.71 localtime.c --- lib/libc/time/localtime.c 17 Aug 2025 08:42:21 -0000 1.71 +++ lib/libc/time/localtime.c 15 Nov 2025 21:19:52 -0000 @@ -1356,7 +1356,7 @@ gmtsub(const time_t *timep, int_fast32_t tmp->tm_zone = wildabbr; else { if (gmtptr == NULL) - tmp->tm_zone = (char *)gmt; + tmp->tm_zone = gmt; else tmp->tm_zone = gmtptr->chars; } Index: lib/libc/time/strptime.c =================================================================== RCS file: /cvs/src/lib/libc/time/strptime.c,v diff -u -p -r1.33 strptime.c --- lib/libc/time/strptime.c 26 Aug 2025 22:30:42 -0000 1.33 +++ lib/libc/time/strptime.c 15 Nov 2025 21:19:07 -0000 @@ -484,7 +484,7 @@ literal: ep = _find_string(bp, &i, nast, NULL, 4); if (ep != NULL) { tm->tm_gmtoff = (-5 - i) * SECSPERHOUR; - tm->tm_zone = (char *)nast[i]; + tm->tm_zone = nast[i]; bp = ep; continue; } @@ -492,7 +492,7 @@ literal: if (ep != NULL) { tm->tm_isdst = 1; tm->tm_gmtoff = (-4 - i) * SECSPERHOUR; - tm->tm_zone = (char *)nadt[i]; + tm->tm_zone = nadt[i]; bp = ep; continue; } Index: usr.bin/finger/lprint.c =================================================================== RCS file: /cvs/src/usr.bin/finger/lprint.c,v diff -u -p -r1.13 lprint.c --- usr.bin/finger/lprint.c 26 Apr 2018 12:42:51 -0000 1.13 +++ usr.bin/finger/lprint.c 15 Nov 2025 20:16:24 -0000 @@ -72,7 +72,7 @@ lprint(PERSON *pn) int cpr, len, maxlen; struct tm *tp; int oddfield; - char *t, *tzn; + const char *t, *tzn; cpr = 0; /*