All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [POSIX][PATCH]pthread_attr_t object should be initialized before using it
@ 2011-01-24  9:28 Bian Naimeng
  2011-02-14 15:07 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Bian Naimeng @ 2011-01-24  9:28 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list

pthread_attr_t object should be initialized before using it.

Signed-off-by: Bian Naimeng <biannm@cn.fujitsu.com>

---
 .../interfaces/pthread_attr_setstacksize/2-1.c     |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c
index 92fb33a..bf2ebc2 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c
@@ -41,14 +41,14 @@ void *thread_func()
 	size_t ssize;
 	int rc;
 
-	if ((rc = pthread_getattr_np(pthread_self(), &attr)) != 0) {
-		printf(ERROR_PREFIX "pthread_getattr_np: %s\n", strerror(rc));
-		exit(PTS_FAIL);
-	}
 	if ((rc = pthread_attr_init(&attr)) != 0) {
 		printf(ERROR_PREFIX "pthread_attr_init: %s\n", strerror(rc));
 		exit(PTS_FAIL);
 	}
+	if ((rc = pthread_getattr_np(pthread_self(), &attr)) != 0) {
+		printf(ERROR_PREFIX "pthread_getattr_np: %s\n", strerror(rc));
+		exit(PTS_FAIL);
+	}
 	if ((rc = pthread_attr_getstacksize(&attr, &ssize)) != 0) {
 		printf(ERROR_PREFIX "pthread_attr_getstacksize: %s\n",
 			strerror(rc));
@@ -127,4 +127,4 @@ int main()
 
 	printf("Test PASSED\n");
 	return PTS_PASS;
-}
\ No newline at end of file
+}
-- 
1.7.0.4



-- 
Regards
Bian Naimeng


------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [LTP] [POSIX][PATCH]pthread_attr_t object should be initialized before using it
  2011-01-24  9:28 [LTP] [POSIX][PATCH]pthread_attr_t object should be initialized before using it Bian Naimeng
@ 2011-02-14 15:07 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2011-02-14 15:07 UTC (permalink / raw)
  To: Bian Naimeng; +Cc: ltp-list

Hi!
> pthread_attr_t object should be initialized before using it.

That seems not to be necessary, at least not here. Did you get randomly
looking stacksizes without this patch as a result?

The problem with this testcase is expecting that the thread gets exactly
the stack size that is defined in attr, but posix says that stacksize is
minimal value to be used for that. So the assertion here should be
ssize >= stack_size.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-02-14 14:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-24  9:28 [LTP] [POSIX][PATCH]pthread_attr_t object should be initialized before using it Bian Naimeng
2011-02-14 15:07 ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.