[PATCH v4 1/4] libuuid: simplify gregorian-to-unix offset calculation
Kiran Rangoon <[email protected]> Tue, 23 Dec 2025 13:00:52 -0500
| Newsgroups | org.kernel.vger.util-linux |
|---|---|
| Message-ID | <[email protected]> |
Replace complex bit-shift offset calculation with a simple constant definition for better readability and maintainability. Signed-off-by: Kiran Rangoon <[email protected]> --- libuuid/src/uuid_time.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libuuid/src/uuid_time.c b/libuuid/src/uuid_time.c index c7516152b..e2b991d74 100644 --- a/libuuid/src/uuid_time.c +++ b/libuuid/src/uuid_time.c @@ -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) -- 2.47.3