Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Feb 2011 21:41:54 +0000
From:      Bruce Cran <brucec@freebsd.org>
To:        bug-followup@freebsd.org, dan@obluda.cz, standards@freebsd.org
Subject:   Re: docs/125751: man 3 pthread_getschedparam section ERRORS incomplete
Message-ID:  <201102222141.54428.brucec@freebsd.org>

next in thread | raw e-mail | index | archive | help
--Boundary-00=_i2CZNPTu+b2EAx0
Content-Type: Text/Plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit

According to POSIX EINVAL isn't a valid return value, which is why it's not 
documented. It appears that if the parameters are NULL 0 is expected to be 
returned; in glibc on Linux if both are NULL then 0 is returned otherwise if 
just one is NULL then a segfault occurs. 

I'd like to commit the attached patch which I think brings the implementation 
more in-line with POSIX: return 0 if either parameters are NULL and return 
ESRCH from functions which search for a pthread_t if a thread doesn't exist 
regardless of whether it's NULL or otherwise.

-- 
Bruce Cran

--Boundary-00=_i2CZNPTu+b2EAx0
Content-Type: text/x-patch;
  charset="ISO-8859-1";
  name="pthread.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="pthread.diff"

Index: thr_list.c
===================================================================
--- thr_list.c	(revision 218951)
+++ thr_list.c	(working copy)
@@ -283,7 +283,7 @@
 
 	if (thread == NULL)
 		/* Invalid thread: */
-		return (EINVAL);
+		return (ESRCH);
 
 	if ((ret = _thr_find_thread(curthread, thread, include_dead)) == 0) {
 		thread->refcount++;
@@ -334,7 +334,7 @@
 	int ret;
 
 	if (thread == NULL)
-		return (EINVAL);
+		return (ESRCH);
 
 	ret = 0;
 	THREAD_LIST_RDLOCK(curthread);
Index: thr_getschedparam.c
===================================================================
--- thr_getschedparam.c	(revision 218951)
+++ thr_getschedparam.c	(working copy)
@@ -51,7 +51,7 @@
 	int ret;
 
 	if (policy == NULL || param == NULL)
-		return (EINVAL);
+		return (0);
 
 	if (pthread == curthread) {
 		/*

--Boundary-00=_i2CZNPTu+b2EAx0--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102222141.54428.brucec>