@@ -51,7 +51,7 @@ static void prvThreadRoutineWrapper( void * pArgument );
5151 * @brief Lock mutex with timeout.
5252 *
5353 * @param[in] pMutex Mutex to lock.
54- * @param[in] timeout timeout value to lock mutex.
54+ * @param[in] timeout Timeout value to lock mutex.
5555 *
5656 * @return ture if mutex is locked successfully. Otherwise false.
5757 */
@@ -76,7 +76,7 @@ static void prvThreadRoutineWrapper( void * pArgument )
7676static bool prIotMutexTimedLock ( PlatformMutex_t * pMutex ,
7777 TickType_t timeout )
7878{
79- BaseType_t lockResult ;
79+ BaseType_t lockResult = pdTRUE ;
8080
8181 configASSERT ( pMutex != NULL );
8282
@@ -103,11 +103,13 @@ bool Platform_CreateDetachedThread( void ( *threadRoutine )( void * ),
103103 size_t stackSize )
104104{
105105 bool status = true;
106+ threadInfo_t * pThreadInfo = NULL ;
106107
107108 configASSERT ( threadRoutine != NULL );
108109
109110 CellularLogDebug ( "Creating new thread." );
110- threadInfo_t * pThreadInfo = Platform_Malloc ( sizeof ( threadInfo_t ) );
111+
112+ pThreadInfo = Platform_Malloc ( sizeof ( threadInfo_t ) );
111113
112114 if ( pThreadInfo == NULL )
113115 {
@@ -116,7 +118,7 @@ bool Platform_CreateDetachedThread( void ( *threadRoutine )( void * ),
116118 }
117119
118120 /* Create the FreeRTOS task that will run the thread. */
119- if ( status )
121+ if ( status == true )
120122 {
121123 pThreadInfo -> threadRoutine = threadRoutine ;
122124 pThreadInfo -> pArgument = pArgument ;
@@ -133,6 +135,10 @@ bool Platform_CreateDetachedThread( void ( *threadRoutine )( void * ),
133135 Platform_Free ( pThreadInfo );
134136 status = false;
135137 }
138+ else
139+ {
140+ CellularLogDebug ( "New thread created." );
141+ }
136142 }
137143
138144 return status ;
@@ -143,21 +149,24 @@ bool Platform_CreateDetachedThread( void ( *threadRoutine )( void * ),
143149bool PlatformMutex_Create ( PlatformMutex_t * pNewMutex ,
144150 bool recursive )
145151{
152+ SemaphoreHandle_t xSemaphore = NULL ;
153+ bool retMutexCreate = false;
154+
146155 configASSERT ( pNewMutex != NULL );
147156
148157 CellularLogDebug ( "Creating new mutex %p." , pNewMutex );
149158
150- if ( recursive )
159+ if ( recursive == true )
151160 {
152- ( void ) xSemaphoreCreateRecursiveMutexStatic ( & pNewMutex -> xMutex );
161+ xSemaphore = xSemaphoreCreateRecursiveMutexStatic ( & pNewMutex -> xMutex );
153162 }
154163 else
155164 {
156- ( void ) xSemaphoreCreateMutexStatic ( & pNewMutex -> xMutex );
165+ xSemaphore = xSemaphoreCreateMutexStatic ( & pNewMutex -> xMutex );
157166 }
158167
159- /* remember the type of mutex */
160- if ( recursive )
168+ /* Remember the type of mutex. */
169+ if ( recursive == true )
161170 {
162171 pNewMutex -> recursive = pdTRUE ;
163172 }
@@ -166,7 +175,17 @@ bool PlatformMutex_Create( PlatformMutex_t * pNewMutex,
166175 pNewMutex -> recursive = pdFALSE ;
167176 }
168177
169- return true;
178+ /* Check the handle value returned by the mutex create function. */
179+ if ( xSemaphore == NULL )
180+ {
181+ retMutexCreate = false;
182+ }
183+ else
184+ {
185+ retMutexCreate = true;
186+ }
187+
188+ return retMutexCreate ;
170189}
171190
172191/*-----------------------------------------------------------*/
0 commit comments