Skip to content

Commit

Permalink
Code review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Aggarwal <[email protected]>
  • Loading branch information
aggarg committed Mar 22, 2023
1 parent 2587c22 commit 74c633a
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 82 deletions.
4 changes: 2 additions & 2 deletions event_groups.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup )

#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
{
/* Check if the event group was statically allocated */
/* Check if the event group was statically allocated. */
if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdTRUE )
{
*ppxEventGroupBuffer = ( StaticEventGroup_t * ) pxEventBits;
Expand All @@ -702,7 +702,7 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup )
}
#else /* configSUPPORT_DYNAMIC_ALLOCATION */
{
/* Event group must have been statically allocated */
/* Event group must have been statically allocated. */
*ppxEventGroupBuffer = ( StaticEventGroup_t * ) pxEventBits;
xReturn = pdTRUE;
}
Expand Down
11 changes: 5 additions & 6 deletions include/event_groups.h
Original file line number Diff line number Diff line change
Expand Up @@ -770,16 +770,15 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
* StaticEventGroup_t ** ppxEventGroupBuffer );
* @endcode
*
* This function fetches a pointer to the memory buffer of a statically created
* event group.
* Retrieve a pointer to a statically created event groups's data structure
* buffer. It is the same buffer that is supplied at the time of creation.
*
* @param xEventGroup The handle of the event group
* @param xEventGroup The event group for which to retrieve the buffer.
*
* @param ppxEventGroupBuffer Used to pass back a pointer to the event groups's
* @param ppxEventGroupBuffer Used to return a pointer to the event groups's
* data structure buffer.
*
* @return pdTRUE if the buffer were fetched. pdFALSE if the event group was not
* statically created.
* @return pdTRUE if the buffer was retrieved, pdFALSE otherwise.
*/
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
BaseType_t xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
Expand Down
20 changes: 10 additions & 10 deletions include/message_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,30 +250,30 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
*
* @code{c}
* BaseType_t xMessageBufferGetStaticBuffers( MessageBufferHandle_t xMessageBuffer,
* uint8_t ** ppucMessageBufferStorageArea,
* StaticMessageBuffer_t ** ppxStaticMessageBuffer );
* uint8_t ** ppucMessageBufferStorageArea,
* StaticMessageBuffer_t ** ppxStaticMessageBuffer );
* @endcode
*
* This function fetches the pointers to the memory buffers of a statically
* created message buffer.
* Retrieve pointers to a statically created message buffer's data structure
* buffer and storage area buffer. These are the same buffers that are supplied
* at the time of creation.
*
* @param xMessageBuffer The handle to the message buffer
* @param xMessageBuffer The message buffer for which to retrieve the buffers.
*
* @param ppucMessageBufferStorageArea Used to pass back a pointer to the
* @param ppucMessageBufferStorageArea Used to return a pointer to the
* message buffer's storage area buffer.
*
* @param ppxStaticMessageBuffer Used to pass back a pointer to the message
* @param ppxStaticMessageBuffer Used to return a pointer to the message
* buffer's data structure buffer.
*
* @return pdTRUE if buffers were fetched. pdFALSE if the message buffer was not
* statically created.
* @return pdTRUE if buffers were retrieved, pdFALSE otherwise..
*
* \defgroup xMessageBufferGetStaticBuffers xMessageBufferGetStaticBuffers
* \ingroup MessageBufferManagement
*/
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
#define xMessageBufferGetStaticBuffers( xMessageBuffer, ppucMessageBufferStorageArea, ppxStaticMessageBuffer ) \
xStreamBufferGenericGetStaticBuffers( ( xMessageBuffer ), ( ppucMessageBufferStorageArea ), ( ppxStaticMessageBuffer ) )
xStreamBufferGetStaticBuffers( ( xMessageBuffer ), ( ppucMessageBufferStorageArea ), ( ppxStaticMessageBuffer ) )
#endif /* configSUPPORT_STATIC_ALLOCATION */

/**
Expand Down
22 changes: 11 additions & 11 deletions include/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,19 +243,19 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t;
* StaticQueue_t ** ppxStaticQueue );
* @endcode
*
* This function fetches the pointers to the memory buffers of a statically
* created queue.
* Retrieve pointers to a statically created queue's data structure buffer
* and storage area buffer. These are the same buffers that are supplied
* at the time of creation.
*
* @param xQueue The handle to the queue
* @param xQueue The queue for which to retrieve the buffers.
*
* @param ppucQueueStorage Used to pass back a pointer to the queue's storage
* @param ppucQueueStorage Used to return a pointer to the queue's storage
* area buffer.
*
* @param ppxStaticQueue Used to pass back a pointer to the queue's data
* @param ppxStaticQueue Used to return a pointer to the queue's data
* structure buffer.
*
* @return pdTRUE if buffers were fetched. pdFALSE if the queue was not
* created using xQueueCreateStatic().
* @return pdTRUE if buffers were retrieved, pdFALSE otherwise.
*
* \defgroup xQueueGetStaticBuffers xQueueGetStaticBuffers
* \ingroup QueueManagement
Expand Down Expand Up @@ -1572,10 +1572,10 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION;
#endif

/*
* Generic version of the function used to get the buffers of statically created
* queues. This is called by other functions and macros that get the buffers
* of other statically created RTOS objects that use the queue structure as
* their base.
* Generic version of the function used to retrieve the buffers of statically
* created queues. This is called by other functions and macros that retrieve
* the buffers of other statically created RTOS objects that use the queue
* structure as their base.
*/
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
BaseType_t xQueueGenericGetStaticBuffers( QueueHandle_t xQueue,
Expand Down
14 changes: 7 additions & 7 deletions include/semphr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1196,16 +1196,16 @@ typedef QueueHandle_t SemaphoreHandle_t;
* BaseType_t xSemaphoreGetStaticBuffer( SemaphoreHandle_t xSemaphore );
* @endcode
*
* This function fetches a pointer to the memory buffer of a statically created
* binary semaphore, counting semaphore, or mutex semaphore.
* Retrieve pointer to a statically created binary semaphore, counting semaphore,
* or mutex semaphore's data structure buffer. This is the same buffer that is
* supplied at the time of creation.
*
* @param xSemaphore The handle of the statically created semaphore
* @param xSemaphore The semaphore for which to retrieve the buffer.
*
* @param ppxSemaphoreBuffer Used to pass back a pointer to the semaphore's
* data structure buffer
* @param ppxSemaphoreBuffer Used to return a pointer to the semaphore's
* data structure buffer.
*
* @return pdTRUE if buffer was fetched. pdFALSE if the semaphore was not
* statically allocated.
* @return pdTRUE if buffer was retrieved, pdFALSE otherwise.
*/
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
#define xSemaphoreGetStaticBuffer( xSemaphore, ppxSemaphoreBuffer ) xQueueGenericGetStaticBuffers( ( QueueHandle_t ) ( xSemaphore ), NULL, ( ppxSemaphoreBuffer ) )
Expand Down
29 changes: 10 additions & 19 deletions include/stream_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,26 +269,27 @@ typedef void (* StreamBufferCallbackFunction_t)( StreamBufferHandle_t xStreamBuf
* StaticStreamBuffer_t ** ppxStaticStreamBuffer );
* @endcode
*
* This function fetches the pointers to the memory buffers of a statically
* created stream buffer.
* Retrieve pointers to a statically created stream buffer's data structure
* buffer and storage area buffer. These are the same buffers that are supplied
* at the time of creation.
*
* @param xStreamBuffer The handle to the stream buffer
* @param xStreamBuffer The stream buffer for which to retrieve the buffers.
*
* @param ppucStreamBufferStorageArea Used to pass back a pointer to the stream
* @param ppucStreamBufferStorageArea Used to return a pointer to the stream
* buffer's storage area buffer.
*
* @param ppxStaticStreamBuffer Used to pass back a pointer to the stream
* @param ppxStaticStreamBuffer Used to return a pointer to the stream
* buffer's data structure buffer.
*
* @return pdTRUE if buffers were fetched. pdFALSE if the stream buffer was not
* statically created.
* @return pdTRUE if buffers were retrieved, pdFALSE otherwise.
*
* \defgroup xStreamBufferGetStaticBuffers xStreamBufferGetStaticBuffers
* \ingroup StreamBufferManagement
*/
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
#define xStreamBufferGetStaticBuffers( xStreamBuffer, ppucStreamBufferStorageArea, ppxStaticStreamBuffer ) \
xStreamBufferGenericGetStaticBuffers( ( xStreamBuffer ), ( ppucStreamBufferStorageArea ), ( ppxStaticStreamBuffer ) )
BaseType_t xStreamBufferGetStaticBuffers( StreamBufferHandle_t xStreamBuffer,
uint8_t ** ppucStreamBufferStorageArea,
StaticStreamBuffer_t ** ppxStaticStreamBuffer ) PRIVILEGED_FUNCTION;
#endif /* configSUPPORT_STATIC_ALLOCATION */

/**
Expand Down Expand Up @@ -926,16 +927,6 @@ StreamBufferHandle_t xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
StreamBufferCallbackFunction_t pxSendCompletedCallback,
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) PRIVILEGED_FUNCTION;

/*
* Generic version of the function used to get the buffers of statically created
* stream or message buffer.
*/
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
BaseType_t xStreamBufferGenericGetStaticBuffers( StreamBufferHandle_t xStreamBuffer,
uint8_t ** ppucStreamBufferStorageArea,
StaticStreamBuffer_t ** ppxStaticStreamBuffer ) PRIVILEGED_FUNCTION;
#endif /* configSUPPORT_STATIC_ALLOCATION */

size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;

#if ( configUSE_TRACE_FACILITY == 1 )
Expand Down
16 changes: 8 additions & 8 deletions include/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -1517,18 +1517,18 @@ TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION; /
* StaticTask_t ** ppxTaskBuffer );
* @endcode
*
* This function fetches a pointer to the memory buffers of a statically created
* task.
* Retrieve pointers to a statically created task's data structure
* buffer and stack buffer. These are the same buffers that are supplied
* at the time of creation.
*
* @param xTask The handle of the statically created task
* @param xTask The task for which to retrieve the buffers.
*
* @param ppuxStackBuffer Used to pass back a pointer to the task's stack buffer
* @param ppuxStackBuffer Used to return a pointer to the task's stack buffer.
*
* @param ppxTaskBuffer Used to pass back a pointer to the task's data structure
* buffer
* @param ppxTaskBuffer Used to return a pointer to the task's data structure
* buffer.
*
* @return pdTRUE if buffers were fetched. pdFALSE if the task was not
* statically created.
* @return pdTRUE if buffers were retrieved, pdFALSE otherwise.
*
* \defgroup xTaskGetStaticBuffers xTaskGetStaticBuffers
* \ingroup TaskUtils
Expand Down
12 changes: 6 additions & 6 deletions include/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1327,16 +1327,16 @@ TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
* BaseType_t xTimerGetStaticBuffer( TimerHandle_t xTimer,
* StaticTimer_t ** ppxTimerBuffer );
*
* This function fetches a pointer to the memory buffer of a statically created
* timer.
* Retrieve pointer to a statically created timer's data structure
* buffer. This is the same buffer that is supplied at the time of
* creation.
*
* @param xTimer The handle of the timer
* @param xTimer The timer for which to retrieve the buffer.
*
* @param ppxTaskBuffer Used to pass back a pointer to the timers's data
* @param ppxTaskBuffer Used to return a pointer to the timers's data
* structure buffer.
*
* @return pdTRUE if the buffer were fetched. pdFALSE if the timer was not
* statically created.
* @return pdTRUE if the buffer was retrieved, pdFALSE otherwise.
*/
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
BaseType_t xTimerGetStaticBuffer( TimerHandle_t xTimer,
Expand Down
4 changes: 2 additions & 2 deletions queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue,

#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
{
/* Check if the queue was statically allocated */
/* Check if the queue was statically allocated. */
if( pxQueue->ucStaticallyAllocated == ( uint8_t ) pdTRUE )
{
if( ppucQueueStorage != NULL )
Expand All @@ -451,7 +451,7 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
}
#else /* configSUPPORT_DYNAMIC_ALLOCATION */
{
/* Queue must have been statically allocated */
/* Queue must have been statically allocated. */
if( ppucQueueStorage != NULL )
{
*ppucQueueStorage = ( uint8_t * ) pxQueue->pcHead;
Expand Down
6 changes: 3 additions & 3 deletions stream_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,9 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
/*-----------------------------------------------------------*/

#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
BaseType_t xStreamBufferGenericGetStaticBuffers( StreamBufferHandle_t xStreamBuffer,
uint8_t ** ppucStreamBufferStorageArea,
StaticStreamBuffer_t ** ppxStaticStreamBuffer )
BaseType_t xStreamBufferGetStaticBuffers( StreamBufferHandle_t xStreamBuffer,
uint8_t ** ppucStreamBufferStorageArea,
StaticStreamBuffer_t ** ppxStaticStreamBuffer )
{
BaseType_t xReturn;
const StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;
Expand Down
21 changes: 13 additions & 8 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2504,15 +2504,13 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char
pxTCB = prvGetTCBFromHandle( xTask );

#if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE == 1 )
if( pxTCB->ucStaticallyAllocated == tskSTATICALLY_ALLOCATED_STACK_AND_TCB )
#endif /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE == 1 */
{
*ppuxStackBuffer = pxTCB->pxStack;
*ppxTaskBuffer = ( StaticTask_t * ) pxTCB;
xReturn = pdTRUE;
}

#if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE == 1 )
if( pxTCB->ucStaticallyAllocated == tskSTATICALLY_ALLOCATED_STACK_AND_TCB )
{
*ppuxStackBuffer = pxTCB->pxStack;
*ppxTaskBuffer = ( StaticTask_t * ) pxTCB;
xReturn = pdTRUE;
}
else if( pxTCB->ucStaticallyAllocated == tskSTATICALLY_ALLOCATED_STACK_ONLY )
{
*ppuxStackBuffer = pxTCB->pxStack;
Expand All @@ -2523,6 +2521,13 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char
{
xReturn = pdFALSE;
}
}
#else /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE == 1 */
{
*ppuxStackBuffer = pxTCB->pxStack;
*ppxTaskBuffer = ( StaticTask_t * ) pxTCB;
xReturn = pdTRUE;
}
#endif /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE == 1 */

return xReturn;
Expand Down

0 comments on commit 74c633a

Please sign in to comment.