Skip to content

Commit

Permalink
Code review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
  • Loading branch information
aggarg committed Mar 25, 2024
1 parent 9c43fea commit 12588c9
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 35 deletions.
21 changes: 14 additions & 7 deletions FreeRTOS/Demo/Posix_GCC/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,23 @@
#define configUSE_ALTERNATIVE_API 0
#define configUSE_QUEUE_SETS 1
#define configUSE_TASK_NOTIFICATIONS 1
/* For static memory allocation , set configSUPPORT_STATIC_ALLOCATION to 1 .
* Since heap_3.c is used in this demo, configSUPPORT_DYNAMIC_ALLOCATION value
* cannot be set to 0. The user can either leave it as it is defined, or remove
* the definition from the file.

/* The following 2 memory allocation schemes are possible for this demo:
*
* 1. Dynamic Only.
* #define configSUPPORT_STATIC_ALLOCATION 0
* #define configSUPPORT_DYNAMIC_ALLOCATION 1
*
* 2. Static and Dynamic.
* #define configSUPPORT_STATIC_ALLOCATION 1
* #define configSUPPORT_DYNAMIC_ALLOCATION 1
*
* Static only configuration is not possible for this demo as it utilizes
* dynamic allocation.
*/
#define configSUPPORT_STATIC_ALLOCATION 1
/* For dynamic memory allocation , set configSUPPORT_STATIC_ALLOCATION to 0
* and configSUPPORT_DYNAMIC_ALLOCATION to 1.
*/
#define configSUPPORT_DYNAMIC_ALLOCATION 1

#define configRECORD_STACK_HIGH_ADDRESS 1

/* Software timer related configuration options. The maximum possible task
Expand Down
2 changes: 1 addition & 1 deletion FreeRTOS/Demo/Posix_GCC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ else
CPPFLAGS += -DprojENABLE_TRACING=0
else
CPPFLAGS += -DprojENABLE_TRACING=1
# Trace Library.
# Trace Library.
SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/kernelports/FreeRTOS/trcKernelPort.c
SOURCE_FILES += $(wildcard ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/*.c )
endif
Expand Down
50 changes: 26 additions & 24 deletions FreeRTOS/Demo/Posix_GCC/code_coverage_additions.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,52 +87,53 @@ static BaseType_t prvTimerQuery( void );
/*-----------------------------------------------------------*/

#if( configSUPPORT_STATIC_ALLOCATION == 1 )

static BaseType_t prvStaticAllocationsWithNullBuffers( void )
{
uintptr_t ulReturned = 0;
BaseType_t xReturn = pdPASS;
UBaseType_t uxDummy = 10;

/* Don't expect to create any of the objects as a NULL parameter is always
* passed in place of a required buffer. Hence if all passes then none of the
|= will be against 0, and ulReturned will still be zero at the end of this
* function. */
* passed in place of a required buffer. Hence if all passes then none of the
* |= will be against 0, and ulReturned will still be zero at the end of this
* function. */
ulReturned |= ( uintptr_t ) xEventGroupCreateStatic( NULL );

/* Try creating a task twice, once with puxStackBuffer NULL, and once with
* pxTaskBuffer NULL. */
* pxTaskBuffer NULL. */
ulReturned |= ( uintptr_t ) xTaskCreateStatic( NULL, /* Task to run, not needed as the task is not created. */
"Dummy", /* Task name. */
configMINIMAL_STACK_SIZE,
NULL,
tskIDLE_PRIORITY,
NULL,
( StaticTask_t * ) &xReturn ); /* Dummy value just to pass a non NULL value in - won't get used. */
"Dummy", /* Task name. */
configMINIMAL_STACK_SIZE,
NULL,
tskIDLE_PRIORITY,
NULL,
( StaticTask_t * ) &xReturn ); /* Dummy value just to pass a non NULL value in - won't get used. */

ulReturned |= ( uintptr_t ) xTaskCreateStatic( NULL, /* Task to run, not needed as the task is not created. */
"Dummy", /* Task name. */
configMINIMAL_STACK_SIZE,
NULL,
tskIDLE_PRIORITY,
( StackType_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */
NULL );
"Dummy", /* Task name. */
configMINIMAL_STACK_SIZE,
NULL,
tskIDLE_PRIORITY,
( StackType_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */
NULL );

ulReturned |= ( uintptr_t ) xQueueCreateStatic( uxDummy,
uxDummy,
( uint8_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */
NULL );

/* Try creating a stream buffer twice, once with pucStreamBufferStorageArea
* set to NULL, and once with pxStaticStreamBuffer set to NULL. */
* set to NULL, and once with pxStaticStreamBuffer set to NULL. */
ulReturned |= ( uintptr_t ) xStreamBufferCreateStatic( uxDummy,
uxDummy,
NULL,
( StaticStreamBuffer_t * ) &xReturn ); /* Dummy value just to pass a non NULL value in - won't get used. */
uxDummy,
NULL,
( StaticStreamBuffer_t * ) &xReturn ); /* Dummy value just to pass a non NULL value in - won't get used. */

ulReturned |= ( uintptr_t ) xStreamBufferCreateStatic( uxDummy,
uxDummy,
( uint8_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */
NULL );
uxDummy,
( uint8_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */
NULL );

if( ulReturned != 0 )
{
Expand All @@ -142,7 +143,8 @@ static BaseType_t prvTimerQuery( void );

return xReturn;
}
#endif /* if( configSUPPORT_STATIC_ALLOCATION == 1 )*/

#endif /* if( configSUPPORT_STATIC_ALLOCATION == 1 ) */
/*-----------------------------------------------------------*/

#if( configUSE_TRACE_FACILITY == 1 )
Expand Down
8 changes: 5 additions & 3 deletions FreeRTOS/Demo/Posix_GCC/main_full.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ static void prvDemonstrateTaskStateAndHandleGetFunctions( void )
xErrorCount++;
}

#if( ( configUSE_TRACE_FACILITY == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
#if( configUSE_TRACE_FACILITY == 1 )
{
/* Also with the vTaskGetInfo() function. */
vTaskGetInfo( xTimerTaskHandle, /* The task being queried. */
Expand All @@ -749,14 +749,16 @@ static void prvDemonstrateTaskStateAndHandleGetFunctions( void )
if( ( xTaskInfo.eCurrentState != eBlocked ) ||
( strcmp( xTaskInfo.pcTaskName, "Tmr Svc" ) != 0 ) ||
( xTaskInfo.uxCurrentPriority != configTIMER_TASK_PRIORITY ) ||
( xTaskInfo.pxStackBase != uxTimerTaskStack ) ||
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
( xTaskInfo.pxStackBase != uxTimerTaskStack ) ||
#endif
( xTaskInfo.xHandle != xTimerTaskHandle ) )
{
pcStatusMessage = "Error: vTaskGetInfo() returned incorrect information about the timer task";
xErrorCount++;
}
}
#endif /* if( ( configUSE_TRACE_FACILITY == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */
#endif /* #if( configUSE_TRACE_FACILITY == 1 ) */

/* Other tests that should only be performed once follow. The test task
* is not created on each iteration because to do so would cause the death
Expand Down

0 comments on commit 12588c9

Please sign in to comment.