@@ -3705,46 +3705,65 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
37053705 if (pthread_mutex_init (& cond -> mutex , NULL ) != 0 )
37063706 return MEMORY_E ;
37073707 if (pthread_cond_init (& cond -> cond , NULL ) != 0 ) {
3708- (void )pthread_mutex_destroy (& cond -> mutex );
3708+ /* Keep compilers happy that we are using the return code */
3709+ if (pthread_mutex_destroy (& cond -> mutex ) != 0 )
3710+ return MEMORY_E ;
37093711 return MEMORY_E ;
37103712 }
37113713 return 0 ;
37123714 }
37133715
37143716 int wolfSSL_CondFree (COND_TYPE * cond )
37153717 {
3718+ int ret = 0 ;
3719+
37163720 if (cond == NULL )
37173721 return BAD_FUNC_ARG ;
37183722
3719- (void )pthread_mutex_destroy (& cond -> mutex );
3720- (void )pthread_cond_destroy (& cond -> cond );
3721- return 0 ;
3723+ if (pthread_mutex_destroy (& cond -> mutex ) != 0 )
3724+ ret = MEMORY_E ;
3725+ if (pthread_cond_destroy (& cond -> cond ) != 0 )
3726+ ret = MEMORY_E ;
3727+
3728+ return ret ;
37223729 }
37233730
37243731 int wolfSSL_CondSignal (COND_TYPE * cond )
37253732 {
3733+ int ret = 0 ;
3734+
37263735 if (cond == NULL )
37273736 return BAD_FUNC_ARG ;
37283737
3729- if (pthread_mutex_lock (& cond -> mutex ) == 0 ) {
3730- (void )pthread_cond_signal (& cond -> cond );
3731- (void )pthread_mutex_unlock (& cond -> mutex );
3732- return 0 ;
3733- }
3734- return BAD_MUTEX_E ;
3738+ if (pthread_mutex_lock (& cond -> mutex ) != 0 )
3739+ return BAD_MUTEX_E ;
3740+
3741+ if (pthread_cond_signal (& cond -> cond ) != 0 )
3742+ ret = MEMORY_E ;
3743+
3744+ if (pthread_mutex_unlock (& cond -> mutex ) != 0 )
3745+ ret = MEMORY_E ;
3746+
3747+ return ret ;
37353748 }
37363749
37373750 int wolfSSL_CondWait (COND_TYPE * cond )
37383751 {
3752+ int ret = 0 ;
3753+
37393754 if (cond == NULL )
37403755 return BAD_FUNC_ARG ;
37413756
3742- if (pthread_mutex_lock (& cond -> mutex ) == 0 ) {
3743- (void )pthread_cond_wait (& cond -> cond , & cond -> mutex );
3744- (void )pthread_mutex_unlock (& cond -> mutex );
3745- return 0 ;
3746- }
3747- return BAD_MUTEX_E ;
3757+ if (pthread_mutex_lock (& cond -> mutex ) != 0 )
3758+ return BAD_MUTEX_E ;
3759+
3760+ if (pthread_cond_wait (& cond -> cond , & cond -> mutex ) != 0 )
3761+ ret = MEMORY_E ;
3762+
3763+ if (pthread_mutex_unlock (& cond -> mutex ) != 0 )
3764+ ret = MEMORY_E ;
3765+
3766+ return ret ;
37483767 }
37493768 #else /* __MACH__ */
37503769 /* Apple style dispatch semaphore */
0 commit comments