From: "Lennart Sorensen" Date: Wed, 10 Jun 2015 16:40:01 -0400 Message-ID: <20150610204001.GG17436@csclub.uwaterloo.ca> References: <20150610203925.GA11561@csclub.uwaterloo.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150610203925.GA11561@csclub.uwaterloo.ca> Subject: Re: [Xenomai] [PATCH] ksrc: Fix pthread_create return value sign when xnthread_register fails List-Id: Discussions about the Xenomai project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: xenomai@xenomai.org On Wed, Jun 10, 2015 at 04:39:25PM -0400, Lennart Sorensen wrote: > 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. > > Signed-off-by: Len Sorensen > --- > ksrc/skins/posix/thread.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/ksrc/skins/posix/thread.c b/ksrc/skins/posix/thread.c > index f1a96f7..05ccf63 100644 > --- a/ksrc/skins/posix/thread.c > +++ b/ksrc/skins/posix/thread.c > @@ -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. */ > -- > 1.7.10.4 This is for xenomai-2.6 -- Len Sorensen