Skip to contentSkip to conversation

alchemy: Correctly translate return value from pthread_mutex_init

PATCH Applied Richard Weinberger 3 participants 6 messages Apr 16, 2023 – Apr 20, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 alchemy: Correctly translate return value from pthread_mutex_init

The alchemy API uses negative error values, so the return value from pthread_mutex_init() needs translation.

---
 lib/alchemy/mutex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/alchemy/mutex.c +1 -1
index f8933858647a..5836af59f05e 100644
@@ -133,7 +133,7 @@ int rt_mutex_create(RT_MUTEX *mutex, const char *name)
 	pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
 	/* pthread_mutexattr_setrobust() might not be implemented. */
 	pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST_NP);
-	ret = __RT(pthread_mutex_init(&mcb->lock, &mattr));
+	ret = -__RT(pthread_mutex_init(&mcb->lock, &mattr));
 	if (ret) {
 		xnfree(mcb);
 		goto out;
Signature · 1 line
2.26.2
Applied
#1 lore raw
Quoted 14 lines · Richard Weinberger

The alchemy API uses negative error values, so the return value from pthread_mutex_init() needs translation.

---
 lib/alchemy/mutex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/alchemy/mutex.c +0 -0
index f8933858647a..5836af59f05e 100644

lib/alchemy/mutex.c int rt_mutex_create(RT_MUTEX *mutex, const char *name) · line 139

Quoted 8 lines
lib/alchemy/mutex.c +1 -1
@@ -133,7 +133,7 @@ int rt_mutex_create(RT_MUTEX *mutex, const char *name)
 	pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
 	/* pthread_mutexattr_setrobust() might not be implemented. */
 	pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST_NP);
-	ret = __RT(pthread_mutex_init(&mcb->lock, &mattr));
+	ret = -__RT(pthread_mutex_init(&mcb->lock, &mattr));
 	if (ret) {
 		xnfree(mcb);
 		goto out;

Thanks, applied.

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
#2 lore raw
Quoted 10 lines · Jan Kiszka
Quoted 9 lines · Richard Weinberger

The alchemy API uses negative error values, so the return value from pthread_mutex_init() needs translation.

---
 lib/alchemy/mutex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

lib/alchemy/mutex.c int rt_mutex_create(RT_MUTEX *mutex, const char *name) · line 139

Quoted 13 lines
lib/alchemy/mutex.c +1 -1
index f8933858647a..5836af59f05e 100644
@@ -133,7 +133,7 @@ int rt_mutex_create(RT_MUTEX *mutex, const char *name)
 	pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
 	/* pthread_mutexattr_setrobust() might not be implemented. */
 	pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST_NP);
-	ret = __RT(pthread_mutex_init(&mcb->lock, &mattr));
+	ret = -__RT(pthread_mutex_init(&mcb->lock, &mattr));
 	if (ret) {
 		xnfree(mcb);
 		goto out;

Thanks, applied.

However, this didn't help with the alchemytest issue I saw, just tried.

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
#3 lore raw
Quoted 28 lines · Jan Kiszka
Quoted 10 lines · Jan Kiszka
Quoted 9 lines · Richard Weinberger

The alchemy API uses negative error values, so the return value from pthread_mutex_init() needs translation.

---
 lib/alchemy/mutex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

lib/alchemy/mutex.c int rt_mutex_create(RT_MUTEX *mutex, const char *name) · line 139

Quoted 13 lines
lib/alchemy/mutex.c +1 -1
index f8933858647a..5836af59f05e 100644
@@ -133,7 +133,7 @@ int rt_mutex_create(RT_MUTEX *mutex, const char *name)
 	pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
 	/* pthread_mutexattr_setrobust() might not be implemented. */
 	pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST_NP);
-	ret = __RT(pthread_mutex_init(&mcb->lock, &mattr));
+	ret = -__RT(pthread_mutex_init(&mcb->lock, &mattr));
 	if (ret) {
 		xnfree(mcb);
 		goto out;

Thanks, applied.

Quoted 2 lines

However, this didn't help with the alchemytest issue I saw, just tried.

BTW, my test setup has --enable-pshared and --enable-registry, maybe that has an influence.

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
#4 lore raw

Hi Jan,

sorry for the late answer, I was pretty busy with some other stuff. I tried reproducing the error in mutex-1 in alchemytests by building with the same options as you:

	--enable-pshared --enable-registry

Unfortunately I cannot reproduce your issue with today's master with the testsuite patches ontop.

On a sidenote: I had to apply following patch to make it build with --enable-registry under my setup:

https://lore.kernel.org/xenomai/[email protected]/T/#t

Aaron

Signature · 2 lines
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT
UID/VAT Nr: ATU 66964118 | FN: 374287y
Quoted 41 lines · Jan Kiszka
Quoted 28 lines · Jan Kiszka
Quoted 10 lines · Jan Kiszka
Quoted 9 lines · Richard Weinberger

The alchemy API uses negative error values, so the return value from pthread_mutex_init() needs translation.

---
 lib/alchemy/mutex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

lib/alchemy/mutex.c int rt_mutex_create(RT_MUTEX *mutex, const char *name) · line 139

Quoted 13 lines
lib/alchemy/mutex.c +1 -1
index f8933858647a..5836af59f05e 100644
@@ -133,7 +133,7 @@ int rt_mutex_create(RT_MUTEX *mutex, const char *name)
 	pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
 	/* pthread_mutexattr_setrobust() might not be implemented. */
 	pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST_NP);
-	ret = __RT(pthread_mutex_init(&mcb->lock, &mattr));
+	ret = -__RT(pthread_mutex_init(&mcb->lock, &mattr));
 	if (ret) {
 		xnfree(mcb);
 		goto out;

Thanks, applied.

Quoted 2 lines

However, this didn't help with the alchemytest issue I saw, just tried.

BTW, my test setup has --enable-pshared and --enable-registry, maybe that has an influence.

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
#5 lore raw
Quoted 11 lines · Aaron Marcher

Hi Jan,

sorry for the late answer, I was pretty busy with some other stuff. I tried reproducing the error in mutex-1 in alchemytests by building with the same options as you:

	--enable-pshared --enable-registry

Unfortunately I cannot reproduce your issue with today's master with the testsuite patches ontop.

Need to try again from a clean rebuild, I thought I did.

Quoted 5 lines

On a sidenote: I had to apply following patch to make it build with --enable-registry under my setup:

https://lore.kernel.org/xenomai/[email protected]/T/#t

Builds fine here. But that snippet was also never submitted as proper patch, was it? Please try to follow up on such build issues soon, specifically as I'd like to roll out a few stable releases these days.

Thanks,
Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux