Skip to contentSkip to conversation

ksrc: Fix pthread_create return value sign when xnthread_register fails

PATCH In review Lennart Sorensen 1 participant 2 messages Jun 10, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ksrc: Fix pthread_create return value sign when xnthread_register fails

xnthread_register returns negative errors, but pthread_create returns positive errors, so the return value has to be negated before being passed on, otherwise the caller of pthread_create will use the return value as a valid thread id.

---
 ksrc/skins/posix/thread.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ksrc/skins/posix/thread.c +1 -1
index f1a96f7..05ccf63 100644
@@ -258,7 +258,7 @@ int pthread_create(pthread_t *tid,
 	ret = xnthread_register(&thread->threadbase, "");
 	if (ret) {
 		thread_destroy(thread);
-		return ret;
+		return -ret;
 	}
 
 	*tid = thread;		/* Must be done before the thread is started. */
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 25 lines · Lennart Sorensen

xnthread_register returns negative errors, but pthread_create returns positive errors, so the return value has to be negated before being passed on, otherwise the caller of pthread_create will use the return value as a valid thread id.

---
 ksrc/skins/posix/thread.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ksrc/skins/posix/thread.c +1 -1
index f1a96f7..05ccf63 100644
@@ -258,7 +258,7 @@ int pthread_create(pthread_t *tid,
 	ret = xnthread_register(&thread->threadbase, "");
 	if (ret) {
 		thread_destroy(thread);
-		return ret;
+		return -ret;
 	}
 
 	*tid = thread;		/* Must be done before the thread is started. */
Signature · 1 line
1.7.10.4

This is for xenomai-2.6

Signature · 1 line
Len Sorensen