Index | Thread | Search

From:
"Theo de Raadt" <deraadt@openbsd.org>
Subject:
Re: date & touch: timegm/mktime checks
To:
Theo Buehler <tb@theobuehler.org>
Cc:
tech@openbsd.org
Date:
Sun, 21 Jun 2026 09:17:16 -0600

Download raw body.

Thread
These look correct.

But they look like useless chicken scratches, which an uneducated developer
might delete later, don't they?

We also don't just want to to this in our tree, but for the idiom to be
copied far and wide.

I think the docs and the landed diffs will fail to educate the outside
community on using this pattern, and the manual page example should be
improved and then idiomatically copied into all the places of use.

Index: time/ctime.3
===================================================================
RCS file: /cvs/src/lib/libc/time/ctime.3,v
diff -u -p -u -r1.55 ctime.3
--- time/ctime.3        21 Jun 2026 08:16:35 -0000      1.55
+++ time/ctime.3        21 Jun 2026 15:10:33 -0000
@@ -406,7 +406,7 @@ did not change from \-1, an error has oc
 .Bd -literal -offset indent
 struct tm tm;
 \&...
-tm.tm_wday = -1;
+tm.tm_wday = -1;       /* sentinel for error */
 if (mktime(&tm) == -1 && tm.tm_wday == -1)
        goto error;
 .Ed

Which means all the tm.tm_wday = -1; in the tree should get that
comment.