HomeClusterLabs Projects

Convert time_t to unsigned long long before formatting (#431)

Description

Convert time_t to unsigned long long before formatting (#431)

Conventionally it's signed long under the GNU C library, which is 32
bits on 32-bit architectures, but Glibc provides the __TIME_BITS==64
option, which makes it signed long long instead (64 bits) and makes no
difference on 64-bit architectures [1]. Since the ping_interval and
pong_timeout members of struct knet_link are unsigned, we can make
this conversion safe by rejecting negative values as well (besides
zero). In the end this enables using the uniform %llu conversion
specifier across all supported architectures. This got exposed by
Debian recently transitioning to 64-bit time_t [2].

[1] https://sourceware.org/glibc/wiki/Y2038ProofnessDesign
[2] https://wiki.debian.org/ReleaseGoals/64bit-time

Signed-off-by: Ferenc Wágner <wferi@debian.org>
Co-authored-by: Ferenc Wágner <wferi@debian.org>

Details

Provenance
fabbioneAuthored on Jul 31 2024, 6:07 AM
chrissie-cCommitted on Jul 31 2024, 6:19 AM
Parents
rK7f4082dd154c: Check packets come from the correct interface
Branches
Unknown
Tags
Unknown
References
stable1-proposed