In some config.log I was seeing this warning:
configure:24322: checking for pthread_mutex_timedlock
configure:24346: gcc -o conftest -g -O2 -I/inst-x86_64-64/include -Wall
-L/inst-x86_64-64/lib conftest.c >&5
conftest.c: In function 'main':
conftest.c:149:25: warning: argument 2 null where non-null expected [-Wnonnull]
149 | return pthread_mutex_timedlock (&lock, (struct
timespec *) 0);
| ^~~~~~~~~~~~~~~~~~~~~~~
This patch fixes it.
2024-08-07 Bruno Haible <[email protected]>
Avoid compiler warnings in some configure tests.
* m4/pthread-rwlock.m4 (gl_PTHREAD_RWLOCK): Allocate more room for local
array 'name'.
* m4/pthread_mutex_timedlock.m4 (gl_FUNC_PTHREAD_MUTEX_TIMEDLOCK): Don't
pass a NULL pointer to pthread_mutex_timedlock.
diff --git a/m4/pthread-rwlock.m4 b/m4/pthread-rwlock.m4
index 51d84419c7..cbd08790e1 100644
--- a/m4/pthread-rwlock.m4
+++ b/m4/pthread-rwlock.m4
@@ -1,5 +1,5 @@
# pthread-rwlock.m4
-# serial 5
+# serial 6
dnl Copyright (C) 2019-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -249,7 +249,7 @@ AC_DEFUN([gl_PTHREAD_RWLOCK]
char **names = (char **) malloc (n * sizeof (char *));
for (size_t i = 0; i < n; i++)
{
- char name[10];
+ char name[12];
sprintf (name, "%c%u", rw_string[i], (unsigned int) (i+1));
names[i] = strdup (name);
}
diff --git a/m4/pthread_mutex_timedlock.m4 b/m4/pthread_mutex_timedlock.m4
index 46b59d793c..9b175d5474 100644
--- a/m4/pthread_mutex_timedlock.m4
+++ b/m4/pthread_mutex_timedlock.m4
@@ -1,5 +1,5 @@
# pthread_mutex_timedlock.m4
-# serial 5
+# serial 6
dnl Copyright (C) 2019-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -28,7 +28,8 @@ AC_DEFUN([gl_FUNC_PTHREAD_MUTEX_TIMEDLOCK]
#include <time.h>
]],
[[pthread_mutex_t lock;
- return pthread_mutex_timedlock (&lock, (struct timespec *) 0);
+ struct timespec ts = { 0 };
+ return pthread_mutex_timedlock (&lock, &ts);
]])
],
[gl_cv_func_pthread_mutex_timedlock_in_LIBMULTITHREAD=yes],