[dm-devel] [PATCH] libmultipath: fix compile error with glibc-2.34+

lixiaokeng lixiaokeng at huawei.com
Wed Aug 11 13:11:43 UTC 2021


There is an error when complie with glibc-2.34:
comparison of integer expressions of different signedness:
'size_t' {aka 'long unsigned int'} and 'long int'
[-Werror=sign-compare]

The reason is that PTHREAD_STACK_MIN may be defined
long int which is  signed in glibc-2.34+. Explicitly assign
it to the size_t variable to  fix it.

Signed-off-by: Lixiaokeng <lixiaokeng at huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26 at huawei.com>
---
 libmultipath/util.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libmultipath/util.c b/libmultipath/util.c
index 0e37f3ff..5c2fd5c6 100644
--- a/libmultipath/util.c
+++ b/libmultipath/util.c
@@ -220,11 +220,12 @@ void
 setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached)
 {
 	int ret;
+	size_t pthread_stack_min = PTHREAD_STACK_MIN;

 	ret = pthread_attr_init(attr);
 	assert(ret == 0);
-	if (stacksize < PTHREAD_STACK_MIN)
-		stacksize = PTHREAD_STACK_MIN;
+	if (stacksize < pthread_stack_min)
+		stacksize = pthread_stack_min;
 	ret = pthread_attr_setstacksize(attr, stacksize);
 	assert(ret == 0);
 	if (detached) {
-- 




More information about the dm-devel mailing list