commit: 31812994d3503b922c6ca74cc7a1fc749736a650
parent ccba48bb598c467cd43fbae317d84900fd5819dc
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 29 Mar 2024 03:17:58 +0100
lib/iso_parse: Handle FreeBSD 14.0 mktime setting errno as side-effect
Diffstat:
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/lib/iso_parse.c b/lib/iso_parse.c
@@ -114,16 +114,15 @@ iso_parse(char *arg, char **errstr)
assert(errno == 0);
time.tv_sec = mktime(&tm);
- if(time.tv_sec == (time_t)-1 || errno != 0)
+ if(time.tv_sec == (time_t)-1)
{
- if(errno == EOVERFLOW)
- *errstr = "result couldn't be represented (EOVERFLOW)";
- else
- *errstr = strerror(errno);
-
- errno = 0;
+ *errstr = strerror(errno);
+ errno = 0;
return time;
}
+ // As observed on FreeBSD 14.0, non-errorneous mktime can still end up setting errno
+ // cf. https://builds.sr.ht/~lanodan/job/1181509
+ errno = 0;
return time;
}