]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
refclock: fix preprocessor conditional
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 19 Jan 2023 10:34:55 +0000 (11:34 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 19 Jan 2023 10:51:41 +0000 (11:51 +0100)
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 <bryan@whatroute.net>
Fixes: badaa83c319a ("refclock: convert mismatched timeval in SOCK messages")
refclock_sock.c

index 2302b9d281050016c2f5be7709c9f2ef5a4cffe8..2da57ef5b43bcc5b21b8008a2ac959423410d9b7 100644 (file)
@@ -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