From 88e711ad9abe3a541863a78efaf8e1b6a143d129 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 19 Jan 2023 11:34:55 +0100 Subject: [PATCH] refclock: fix preprocessor conditional Split the new SOCK conditional using __GLIBC_PREREQ macro (which has arguments) to fix compilation when it is not defined. Fix also debug message using sizeof(time_t) in case it's enabled on 64-bit systems. Reported-by: Bryan Christianson Fixes: badaa83c319a ("refclock: convert mismatched timeval in SOCK messages") --- refclock_sock.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/refclock_sock.c b/refclock_sock.c index 2302b9d..2da57ef 100644 --- a/refclock_sock.c +++ b/refclock_sock.c @@ -61,7 +61,8 @@ struct sock_sample { /* On 32-bit glibc-based systems enable conversion between timevals using 32-bit and 64-bit time_t to support SOCK clients compiled with different time_t size than chrony */ -#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 34) && __TIMESIZE == 32 +#ifdef __GLIBC_PREREQ +#if __GLIBC_PREREQ(2, 34) && __TIMESIZE == 32 #define CONVERT_TIMEVAL 1 #if defined(_TIME_BITS) && _TIME_BITS == 64 typedef int32_t alt_time_t; @@ -75,6 +76,7 @@ struct alt_timeval { alt_suseconds_t tv_usec; }; #endif +#endif static void read_sample(int sockfd, int event, void *anything) { @@ -108,7 +110,7 @@ static void read_sample(int sockfd, int event, void *anything) #endif sample.tv.tv_sec = atv.tv_sec; sample.tv.tv_usec = atv.tv_usec; - DEBUG_LOG("Converted %u-bit timeval", 8 * sizeof (alt_time_t)); + DEBUG_LOG("Converted %d-bit timeval", 8 * (int)sizeof (alt_time_t)); memcpy((char *)&sample + sizeof (struct timeval), buf + sizeof (struct alt_timeval), sizeof (sample) - sizeof (struct timeval)); #endif