@@ -235,28 +235,20 @@ int tst_thread_cleanup (struct tst_thread_env_t ** thread_env)
235
235
return 0 ;
236
236
}
237
237
238
- /*
239
- * Returns the thread ID of the current thread
238
+ /** \brief Return thread ID of the current thread
239
+ *
240
+ * \return Success: thread ID, Fail: -1
240
241
*/
241
- inline int tst_thread_get_num (void )
242
- {
242
+ inline int tst_thread_get_num () {
243
+ assert (num_threads > 0 );
244
+ assert (NULL != tst_thread_tid_array );
243
245
int i = 0 ;
244
246
pthread_t self = pthread_self ();
245
- tst_output_printf (DEBUG_LOG , TST_REPORT_MAX , "Searching for thread_id %p\n" , self );
246
-
247
- if (NULL == tst_thread_tid_array ) {
248
- return 0 ;
249
- }
250
247
for (i = 0 ; i <= num_threads ; i ++ ) {
251
- tst_output_printf (DEBUG_LOG , TST_REPORT_MAX , "Comparing with thread_id %p ...." , tst_thread_tid_array [i ]);
252
- if ( pthread_equal (tst_thread_tid_array [i ], self ) ) {
253
- tst_output_printf (DEBUG_LOG , TST_REPORT_MAX , "Found :-) Return %d\n" , i );
254
- return i ;
255
- }
256
- else
257
- tst_output_printf (DEBUG_LOG , TST_REPORT_MAX , "Not equal\n" );
248
+ if (pthread_equal (tst_thread_tid_array [i ], self )) {
249
+ return i ;
250
+ }
258
251
}
259
- ERROR (EINVAL , "Thread ID could not be determined" );
260
252
return -1 ;
261
253
}
262
254
0 commit comments