Skip to content

Commit cce8d1e

Browse files
Merge branch 'main' into fixParadigmFormatting
2 parents 27a62f2 + de2c0c1 commit cce8d1e

File tree

14 files changed

+331
-148
lines changed

14 files changed

+331
-148
lines changed

MISRA.md

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,37 @@ grep 'MISRA Ref 8.4.1' . -rI
2121
#### Rule 8.4
2222

2323
MISRA C:2012 Rule 8.4: A compatible declaration shall be visible when an
24-
object or function with external linkage is defined.
24+
object or function with external linkage is defined.
2525

2626
_Ref 8.4.1_
27+
- pxCurrentTCB(s) is defined with external linkage but it is only referenced
28+
from the assembly code in the port files. Therefore, adding a declaration in
29+
header file is not useful as the assembly code will still need to declare it
30+
separately.
2731

28-
- This rule requires that a compatible declaration is made available
29-
in a header file when an object with external linkage is defined.
30-
pxCurrentTCB(s) is defined with external linkage but it is only
31-
referenced from the assembly code in the port files. Therefore, adding
32-
a declaration in header file is not useful as the assembly code will
33-
still need to declare it separately.
32+
_Ref 8.4.2_
33+
- xQueueRegistry is defined with external linkage because it is accessed by the
34+
kernel unit tests. It is not meant to be directly accessed by the application
35+
and therefore, not declared in a header file.
3436

37+
#### Rule 8.6
38+
39+
MISRA C:2012 Rule 8.6: An identifier with external linkage shall have exactly
40+
one external definition.
41+
42+
_Ref 8.6.1_
43+
- This rule prohibits an identifier with external linkage to have multiple
44+
definitions or no definition. FreeRTOS hook functions are implemented in
45+
the application and therefore, have no definition in the Kernel code.
46+
47+
#### Rule 11.1
48+
MISRA C:2012 Rule 11.1: Conversions shall not be performed between a pointer to
49+
function and any other type.
50+
51+
_Ref 11.1.1_
52+
- The pointer to function is casted into void to avoid unused parameter
53+
compiler warning when Stream Buffer's Tx and Rx Completed callback feature is
54+
not used.
3555

3656
#### Rule 11.3
3757

@@ -87,6 +107,15 @@ _Ref 11.5.5_
87107
because data storage buffers are implemented as uint8_t arrays for the
88108
ease of sizing, alignment and access.
89109

110+
#### Rule 21.6
111+
112+
MISRA C-2012 Rule 21.6: The Standard Library input/output functions shall not
113+
be used.
114+
115+
_Ref 21.6.1_
116+
- The Standard Library function snprintf is used in vTaskListTasks and
117+
vTaskGetRunTimeStatistics APIs, both of which are utility functions only and
118+
are not considered part of core kernel implementation.
90119

91120
### MISRA configuration
92121

event_groups.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup,
506506
traceENTER_xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear );
507507

508508
traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear );
509-
xReturn = xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL ); /*lint !e9087 Can't avoid cast to void* as a generic callback function not specific to this use case. Callback casts back to original type so safe. */
509+
xReturn = xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL );
510510

511511
traceRETURN_xEventGroupClearBitsFromISR( xReturn );
512512

@@ -735,7 +735,7 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup )
735735
/* For internal use only - execute a 'set bits' command that was pended from
736736
* an interrupt. */
737737
void vEventGroupSetBitsCallback( void * pvEventGroup,
738-
const uint32_t ulBitsToSet )
738+
uint32_t ulBitsToSet )
739739
{
740740
traceENTER_vEventGroupSetBitsCallback( pvEventGroup, ulBitsToSet );
741741

@@ -751,7 +751,7 @@ void vEventGroupSetBitsCallback( void * pvEventGroup,
751751
/* For internal use only - execute a 'clear bits' command that was pended from
752752
* an interrupt. */
753753
void vEventGroupClearBitsCallback( void * pvEventGroup,
754-
const uint32_t ulBitsToClear )
754+
uint32_t ulBitsToClear )
755755
{
756756
traceENTER_vEventGroupClearBitsCallback( pvEventGroup, ulBitsToClear );
757757

@@ -812,7 +812,7 @@ static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits,
812812
traceENTER_xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken );
813813

814814
traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet );
815-
xReturn = xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken ); /*lint !e9087 Can't avoid cast to void* as a generic callback function not specific to this use case. Callback casts back to original type so safe. */
815+
xReturn = xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken );
816816

817817
traceRETURN_xEventGroupSetBitsFromISR( xReturn );
818818

include/event_groups.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,9 +807,9 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
807807

808808
/* For internal use only. */
809809
void vEventGroupSetBitsCallback( void * pvEventGroup,
810-
const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION;
810+
uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION;
811811
void vEventGroupClearBitsCallback( void * pvEventGroup,
812-
const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
812+
uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
813813

814814

815815
#if ( configUSE_TRACE_FACILITY == 1 )

include/queue.h

Lines changed: 70 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,8 @@ BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FU
14551455
BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
14561456
UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
14571457

1458+
#if ( configUSE_CO_ROUTINES == 1 )
1459+
14581460
/*
14591461
* The functions defined above are for passing data to and from tasks. The
14601462
* functions below are the equivalents for passing data to and from
@@ -1464,36 +1466,51 @@ UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEG
14641466
* should not be called directly from application code. Instead use the macro
14651467
* wrappers defined within croutine.h.
14661468
*/
1467-
BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue,
1468-
const void * pvItemToQueue,
1469-
BaseType_t xCoRoutinePreviouslyWoken );
1470-
BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue,
1471-
void * pvBuffer,
1472-
BaseType_t * pxTaskWoken );
1473-
BaseType_t xQueueCRSend( QueueHandle_t xQueue,
1474-
const void * pvItemToQueue,
1475-
TickType_t xTicksToWait );
1476-
BaseType_t xQueueCRReceive( QueueHandle_t xQueue,
1477-
void * pvBuffer,
1478-
TickType_t xTicksToWait );
1469+
BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue,
1470+
const void * pvItemToQueue,
1471+
BaseType_t xCoRoutinePreviouslyWoken );
1472+
BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue,
1473+
void * pvBuffer,
1474+
BaseType_t * pxTaskWoken );
1475+
BaseType_t xQueueCRSend( QueueHandle_t xQueue,
1476+
const void * pvItemToQueue,
1477+
TickType_t xTicksToWait );
1478+
BaseType_t xQueueCRReceive( QueueHandle_t xQueue,
1479+
void * pvBuffer,
1480+
TickType_t xTicksToWait );
1481+
1482+
#endif /* if ( configUSE_CO_ROUTINES == 1 ) */
14791483

14801484
/*
14811485
* For internal use only. Use xSemaphoreCreateMutex(),
14821486
* xSemaphoreCreateCounting() or xSemaphoreGetMutexHolder() instead of calling
14831487
* these functions directly.
14841488
*/
14851489
QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
1486-
QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType,
1487-
StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
1488-
QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount,
1489-
const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION;
1490-
QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
1491-
const UBaseType_t uxInitialCount,
1492-
StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
1490+
1491+
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1492+
QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType,
1493+
StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
1494+
#endif
1495+
1496+
#if ( configUSE_COUNTING_SEMAPHORES == 1 )
1497+
QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount,
1498+
const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION;
1499+
#endif
1500+
1501+
#if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
1502+
QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
1503+
const UBaseType_t uxInitialCount,
1504+
StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
1505+
#endif
1506+
14931507
BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue,
14941508
TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
1495-
TaskHandle_t xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION;
1496-
TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION;
1509+
1510+
#if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
1511+
TaskHandle_t xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION;
1512+
TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION;
1513+
#endif
14971514

14981515
/*
14991516
* For internal use only. Use xSemaphoreTakeMutexRecursive() or
@@ -1653,7 +1670,9 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION;
16531670
* @return If the queue set is created successfully then a handle to the created
16541671
* queue set is returned. Otherwise NULL is returned.
16551672
*/
1656-
QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILEGED_FUNCTION;
1673+
#if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
1674+
QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILEGED_FUNCTION;
1675+
#endif
16571676

16581677
/*
16591678
* Adds a queue or semaphore to a queue set that was previously created by a
@@ -1677,8 +1696,10 @@ QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILE
16771696
* queue set because it is already a member of a different queue set then pdFAIL
16781697
* is returned.
16791698
*/
1680-
BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore,
1681-
QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
1699+
#if ( configUSE_QUEUE_SETS == 1 )
1700+
BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore,
1701+
QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
1702+
#endif
16821703

16831704
/*
16841705
* Removes a queue or semaphore from a queue set. A queue or semaphore can only
@@ -1697,8 +1718,10 @@ BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore,
16971718
* then pdPASS is returned. If the queue was not in the queue set, or the
16981719
* queue (or semaphore) was not empty, then pdFAIL is returned.
16991720
*/
1700-
BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
1701-
QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
1721+
#if ( configUSE_QUEUE_SETS == 1 )
1722+
BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
1723+
QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
1724+
#endif
17021725

17031726
/*
17041727
* xQueueSelectFromSet() selects from the members of a queue set a queue or
@@ -1734,24 +1757,38 @@ BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
17341757
* in the queue set that is available, or NULL if no such queue or semaphore
17351758
* exists before before the specified block time expires.
17361759
*/
1737-
QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet,
1738-
const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
1760+
#if ( configUSE_QUEUE_SETS == 1 )
1761+
QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet,
1762+
const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
1763+
#endif
17391764

17401765
/*
17411766
* A version of xQueueSelectFromSet() that can be used from an ISR.
17421767
*/
1743-
QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
1768+
#if ( configUSE_QUEUE_SETS == 1 )
1769+
QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
1770+
#endif
17441771

17451772
/* Not public API functions. */
17461773
void vQueueWaitForMessageRestricted( QueueHandle_t xQueue,
17471774
TickType_t xTicksToWait,
17481775
const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;
17491776
BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
17501777
BaseType_t xNewQueue ) PRIVILEGED_FUNCTION;
1751-
void vQueueSetQueueNumber( QueueHandle_t xQueue,
1752-
UBaseType_t uxQueueNumber ) PRIVILEGED_FUNCTION;
1753-
UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
1754-
uint8_t ucQueueGetQueueType( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
1778+
1779+
#if ( configUSE_TRACE_FACILITY == 1 )
1780+
void vQueueSetQueueNumber( QueueHandle_t xQueue,
1781+
UBaseType_t uxQueueNumber ) PRIVILEGED_FUNCTION;
1782+
#endif
1783+
1784+
#if ( configUSE_TRACE_FACILITY == 1 )
1785+
UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
1786+
#endif
1787+
1788+
#if ( configUSE_TRACE_FACILITY == 1 )
1789+
uint8_t ucQueueGetQueueType( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
1790+
#endif
1791+
17551792
UBaseType_t uxQueueGetQueueItemSize( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
17561793
UBaseType_t uxQueueGetQueueLength( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
17571794

0 commit comments

Comments
 (0)