pthread_attr_t object should be initialized before using it
PATCH 1/1 pthread_attr_t object should be initialized before using it
pthread_attr_t object should be initialized before using it.
Signed-off-by Bian Naimeng <[email protected]>
--- .../interfaces/pthread_attr_setstacksize/2-1.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c +5 -5
@@ -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 ; -} +}
Signature · 19 lines
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 [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Quoted 1 line
pthread_attr_tobject 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.
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ 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 [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list