chiark / gitweb /
time: time_t is signed, and mktime() is happy to return negative time
authorLennart Poettering <lennart@poettering.net>
Thu, 2 Feb 2017 17:25:33 +0000 (18:25 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 17 Jul 2017 15:58:36 +0000 (17:58 +0200)
commit6357ed92bd48120109f246b34e0fa8977a2caedc
tree6ecce61fa5d5ab97ade4d6fa6b1c6a490c4a4f37
parent0a1154544763e1e1ceec84b21ee87a101fbfb19a
time: time_t is signed, and mktime() is happy to return negative time

Passing a year such as 1960 to mktime() will result in a negative return
value. This is quite confusing, as the man page claims that on failure
the call will return -1...

Given that our own usec_t type is unsigned, and we can't express times
before 1970 hence, let's consider all negative times returned by
mktime() as invalid, regardless if just -1, or anything else negative.
src/basic/time-util.c