]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libuuid: simplify gregorian-to-unix offset calculation
authorKiran Rangoon <kiranrangoon0@gmail.com>
Mon, 29 Dec 2025 03:50:57 +0000 (22:50 -0500)
committerThomas Weißschuh <thomas@t-8ch.de>
Mon, 29 Dec 2025 13:42:52 +0000 (14:42 +0100)
Replace complex bit-shift offset calculation with a simple constant
definition for better readability and maintainability.

Signed-off-by: Kiran Rangoon <kiranrangoon0@gmail.com>
Reviewed-by: Thomas Weißschuh <thomas@t-8ch.de>
libuuid/src/uuid_time.c

index c7516152b53aa521529dcad200a430c6a91d20cf..e2b991d745731b1ee0ab918030d97fd228fb6ca1 100644 (file)
@@ -62,7 +62,8 @@ time_t __uuid_time(const uuid_t uu, struct timeval *ret_tv);
 
 static uint64_t gregorian_to_unix(uint64_t ts)
 {
-       return ts - ((((uint64_t) 0x01B21DD2) << 32) + 0x13814000);
+       const uint64_t offset = 0x01B21DD213814000ULL;
+       return ts - offset;
 }
 
 static void uuid_time_v1(const struct uuid *uuid, struct timeval *tv)