Skip to content

Commit 2e38eb5

Browse files
committed
Address warnings introduced in PR FreeRTOS#1223
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
1 parent 42135c1 commit 2e38eb5

File tree

1 file changed

+44
-21
lines changed
  • portable/ThirdParty/GCC/Posix

1 file changed

+44
-21
lines changed

portable/ThirdParty/GCC/Posix/port.c

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,20 @@ static void prvResumeThread( Thread_t * xThreadId );
119119
static void vPortSystemTickHandler( int sig );
120120
static void vPortStartFirstTask( void );
121121
static void prvPortYieldFromISR( void );
122+
static void prvThreadKeyDestructor( void * pvData );
123+
static void prvInitThreadKey( void );
124+
static void prvMarkAsFreeRTOSThread( void );
125+
static BaseType_t prvIsFreeRTOSThread( void );
126+
static void prvDestroyThreadKey( void );
122127
/*-----------------------------------------------------------*/
123128

124-
void prvThreadKeyDestructor( void * data )
129+
static void prvThreadKeyDestructor( void * pvData )
125130
{
126-
free( data );
131+
free( pvData );
127132
}
133+
/*-----------------------------------------------------------*/
128134

129-
static void prvInitThreadKey()
135+
static void prvInitThreadKey( void )
130136
{
131137
pthread_mutex_lock( &xThreadMutex );
132138

@@ -137,24 +143,39 @@ static void prvInitThreadKey()
137143

138144
pthread_mutex_unlock( &xThreadMutex );
139145
}
146+
/*-----------------------------------------------------------*/
140147

141-
static void prvMarkAsFreeRTOSThread( pthread_t thread )
148+
static void prvMarkAsFreeRTOSThread( void )
142149
{
150+
uint8_t * pucThreadData = NULL;
151+
143152
prvInitThreadKey();
144-
uint8_t * thread_data = malloc( 1 );
145-
configASSERT( thread_data != NULL );
146-
*thread_data = 1;
147-
pthread_setspecific( xThreadKey, thread_data );
153+
154+
pucThreadData = malloc( 1 );
155+
configASSERT( pucThreadData != NULL );
156+
157+
*pucThreadData = 1;
158+
159+
pthread_setspecific( xThreadKey, pucThreadData );
148160
}
161+
/*-----------------------------------------------------------*/
149162

150-
static BaseType_t prvIsFreeRTOSThread( pthread_t thread )
163+
static BaseType_t prvIsFreeRTOSThread( void )
151164
{
152-
uint8_t * thread_data = ( uint8_t * ) pthread_getspecific( xThreadKey );
165+
uint8_t * pucThreadData = NULL;
166+
BaseType_t xRet = pdFALSE;
153167

154-
return thread_data != NULL && *thread_data == 1;
168+
pucThreadData = ( uint8_t * ) pthread_getspecific( xThreadKey );
169+
if( ( pucThreadData != NULL ) && ( *pucThreadData == 1 ) )
170+
{
171+
xRet = pdTRUE;
172+
}
173+
174+
return xRet;
155175
}
176+
/*-----------------------------------------------------------*/
156177

157-
static void prvDestroyThreadKey()
178+
static void prvDestroyThreadKey( void )
158179
{
159180
pthread_key_delete( xThreadKey );
160181
}
@@ -309,7 +330,7 @@ void vPortEndScheduler( void )
309330
( void ) pthread_kill( hMainThread, SIG_RESUME );
310331

311332
/* Waiting to be deleted here. */
312-
if( prvIsFreeRTOSThread( pthread_self() ) == pdTRUE )
333+
if( prvIsFreeRTOSThread() == pdTRUE )
313334
{
314335
pxCurrentThread = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
315336
event_wait( pxCurrentThread->ev );
@@ -369,7 +390,7 @@ void vPortYield( void )
369390

370391
void vPortDisableInterrupts( void )
371392
{
372-
if( prvIsFreeRTOSThread( pthread_self() ) == pdTRUE )
393+
if( prvIsFreeRTOSThread() == pdTRUE )
373394
{
374395
pthread_sigmask(SIG_BLOCK, &xAllSignals, NULL);
375396
}
@@ -378,9 +399,9 @@ void vPortDisableInterrupts( void )
378399

379400
void vPortEnableInterrupts( void )
380401
{
381-
if( prvIsFreeRTOSThread( pthread_self() ) == pdTRUE )
402+
if( prvIsFreeRTOSThread() == pdTRUE )
382403
{
383-
pthread_sigmask(SIG_UNBLOCK, &xAllSignals, NULL);
404+
pthread_sigmask( SIG_UNBLOCK, &xAllSignals, NULL );
384405
}
385406
}
386407
/*-----------------------------------------------------------*/
@@ -417,9 +438,9 @@ static void * prvTimerTickHandler( void * arg )
417438
{
418439
( void ) arg;
419440

420-
prvMarkAsFreeRTOSThread( pthread_self() );
441+
prvMarkAsFreeRTOSThread();
421442

422-
prvPortSetCurrentThreadName("Scheduler timer");
443+
prvPortSetCurrentThreadName( "Scheduler timer" );
423444

424445
while( xTimerTickThreadShouldRun )
425446
{
@@ -451,7 +472,7 @@ void prvSetupTimerInterrupt( void )
451472

452473
static void vPortSystemTickHandler( int sig )
453474
{
454-
if( prvIsFreeRTOSThread( pthread_self() ) == pdTRUE )
475+
if( prvIsFreeRTOSThread() == pdTRUE )
455476
{
456477
Thread_t * pxThreadToSuspend;
457478
Thread_t * pxThreadToResume;
@@ -473,7 +494,9 @@ static void vPortSystemTickHandler( int sig )
473494
}
474495

475496
uxCriticalNesting--;
476-
} else {
497+
}
498+
else
499+
{
477500
fprintf( stderr, "vPortSystemTickHandler called from non-FreeRTOS thread\n" );
478501
}
479502
}
@@ -508,7 +531,7 @@ static void * prvWaitForStart( void * pvParams )
508531
{
509532
Thread_t * pxThread = pvParams;
510533

511-
prvMarkAsFreeRTOSThread( pthread_self() );
534+
prvMarkAsFreeRTOSThread();
512535

513536
prvSuspendSelf( pxThread );
514537

0 commit comments

Comments
 (0)