]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
configure: fix compiler warnings in system function checks
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 14 Aug 2025 11:55:54 +0000 (13:55 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 14 Aug 2025 12:25:38 +0000 (14:25 +0200)
Avoid using (void *)1 as an output buffer to fix detection of supported
system functions due to -Werror and -Wstringop-overflow etc.

configure

index 58159de58eb0eabd3c181117165715c221eaa7be..195b1ed7076b9b90c072222f9cbb9098ffcafc52 100755 (executable)
--- a/configure
+++ b/configure
@@ -666,13 +666,15 @@ then
 fi
 
 if [ $try_clock_gettime = "1" ]; then
-  if test_code 'clock_gettime()' 'time.h' '' '' \
-    'clock_gettime(CLOCK_REALTIME, (void *)1);'
+  if test_code 'clock_gettime()' 'time.h' '' '' '
+    struct timespec ts;
+    clock_gettime(CLOCK_REALTIME, &ts);'
   then
     add_def HAVE_CLOCK_GETTIME
   else
-    if test_code 'clock_gettime() in -lrt' 'time.h' '' '-lrt' \
-      'clock_gettime(CLOCK_REALTIME, (void *)1);'
+    if test_code 'clock_gettime() in -lrt' 'time.h' '' '-lrt' '
+      struct timespec ts;
+      clock_gettime(CLOCK_REALTIME, &ts);'
     then
       add_def HAVE_CLOCK_GETTIME
       EXTRA_LIBS="$EXTRA_LIBS -lrt"
@@ -699,13 +701,16 @@ else
 fi
 
 if [ $try_arc4random = "1" ] && \
-  test_code 'arc4random_buf()' 'stdlib.h' '' '' \
-    'arc4random_buf((void *)1, 1);'
+  test_code 'arc4random_buf()' 'stdlib.h' '' '' '
+    char c;
+    arc4random_buf(&c, 1);'
 then
   add_def HAVE_ARC4RANDOM
 else
-  if test_code 'getrandom()' 'stdlib.h sys/random.h' '' '' \
-      'return getrandom((void *)1, 1, 0);'; then
+  if test_code 'getrandom()' 'stdlib.h sys/random.h' '' '' '
+    char c;
+    return getrandom(&c, 1, 0);'
+  then
     add_def HAVE_GETRANDOM
   fi
 fi