Skip to contentSkip to conversation

libmultipath: fix compile error with glibc-2.34+

PATCH In review lixiaokeng 2 participants 3 messages Aug 11, 2021 – Aug 12, 2021 Device mapper

lore
Share & tools
lore

lixiaokeng

author
#0 lore raw

PATCH 1/1 libmultipath: fix compile error with glibc-2.34+

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.

---
 libmultipath/util.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
libmultipath/util.c +3 -2
index 0e37f3ff..5c2fd5c6 100644
@@ -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) {
Signature · 4 lines
--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#1 lore raw

Hello Lixiaokeng,

Quoted 11 lines · lixiaokeng

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.

Thanks! Ben had already submitted a patch for this in
https://listman.redhat.com/archives/dm-devel/2021-July/msg00159.html.

Ben's patch handles the error case (-1) more correctly.

Regards
Martin

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

author
#2 lore raw
Quoted 15 lines · Martin Wilck

Hello Lixiaokeng,

Quoted 11 lines · lixiaokeng

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.

Quoted 9 lines

Thanks! Ben had already submitted a patch for this in
https://listman.redhat.com/archives/dm-devel/2021-July/msg00159.html.

Ben's patch handles the error case (-1) more correctly.

Regards
Martin

Thanks for reply, I will using Ben's patch to replace my patch.

Regards,
Lixiaokeng

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel