]> git.sur5r.net Git - freertos/commitdiff
TimerHandle_t is now type safe instead of void *.
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 11 Jun 2018 04:43:12 +0000 (04:43 +0000)
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 11 Jun 2018 04:43:12 +0000 (04:43 +0000)
Remove casts that are no longer required not type safe handles are used.

git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2545 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Source/include/list.h
FreeRTOS/Source/include/stack_macros.h
FreeRTOS/Source/include/timers.h
FreeRTOS/Source/stream_buffer.c
FreeRTOS/Source/tasks.c
FreeRTOS/Source/timers.c

index 2ec4a67c9d106c7ae462723c5151856f8a990a4c..6457258b2f7bdd2a5da32fa660a0efcaaef7826a 100644 (file)
@@ -315,7 +315,7 @@ List_t * const pxConstList = ( pxList );                                                                                                    \
  * @param pxListItem The list item we want to know if is in the list.\r
  * @return pdTRUE if the list item is in the list, otherwise pdFALSE.\r
  */\r
-#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( ( pxListItem )->pxContainer == ( pxList ) ) ? pdTRUE : pdFALSE )\r
+#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( ( pxListItem )->pxContainer == ( pxList ) ) ? ( pdTRUE ) : ( pdFALSE ) )\r
 \r
 /*\r
  * Return the list a list item is contained within (referenced from).\r
index e8515b35a39827e3fc4f2a900e0bf4155887557d..d59afc4e866e8f06b278eaca0cbc564c98b556ce 100644 (file)
                const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack;                                                 \\r
                const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5;                                                                                  \\r
                                                                                                                                                                                                                \\r
-               if( ( pulStack[ 0 ] != ulCheckValue ) ||                                                                                                \\r
-                       ( pulStack[ 1 ] != ulCheckValue ) ||                                                                                            \\r
-                       ( pulStack[ 2 ] != ulCheckValue ) ||                                                                                            \\r
-                       ( pulStack[ 3 ] != ulCheckValue ) )                                                                                             \\r
+               if( ( pulStack[ 0 ] != ulCheckValue ) ||                                                                                                                \\r
+                       ( pulStack[ 1 ] != ulCheckValue ) ||                                                                                                            \\r
+                       ( pulStack[ 2 ] != ulCheckValue ) ||                                                                                                            \\r
+                       ( pulStack[ 3 ] != ulCheckValue ) )                                                                                                                     \\r
                {                                                                                                                                                                                               \\r
                        vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName );       \\r
                }                                                                                                                                                                                               \\r
index 7e2eceb169275f3fb51953c57de0d5e806d211b9..4b1a3402f6edd915f868eaae82404cde587dd175 100644 (file)
@@ -73,7 +73,8 @@ or interrupt version of the queue send function should be used. */
  * reference the subject timer in calls to other software timer API functions\r
  * (for example, xTimerStart(), xTimerReset(), etc.).\r
  */\r
-typedef void * TimerHandle_t;\r
+struct TimerDef_t;\r
+typedef struct TimerDef_t * TimerHandle_t;\r
 \r
 /*\r
  * Defines the prototype to which timer callback functions must conform.\r
index 71355f5cbbd172fdba944925c584565c3a89fccb..392d04d37007ad44ff9e3b3d9e88eb889cb0db75 100644 (file)
@@ -367,7 +367,7 @@ StreamBuffer_t * pxStreamBuffer = xStreamBuffer;
 \r
 BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer )\r
 {\r
-StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */\r
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
 BaseType_t xReturn = pdFAIL, xIsMessageBuffer;\r
 \r
 #if( configUSE_TRACE_FACILITY == 1 )\r
index fb34246291b9d1ae71e52188ba8235125eb28a3b..579874a14a7d90dcde4c3c4820ed6439c73f2ea8 100644 (file)
@@ -2824,7 +2824,7 @@ BaseType_t xSwitchRequired = pdFALSE;
                }\r
                else\r
                {\r
-                       xTCB = ( TCB_t * ) xTask;\r
+                       xTCB = xTask;\r
                }\r
 \r
                /* Save the hook function in the TCB.  A critical section is required as\r
@@ -2851,7 +2851,7 @@ BaseType_t xSwitchRequired = pdFALSE;
                /* If xTask is NULL then we are calling our own task hook. */\r
                if( xTask == NULL )\r
                {\r
-                       xTCB = ( TCB_t * ) pxCurrentTCB;\r
+                       xTCB = pxCurrentTCB;\r
                }\r
                else\r
                {\r
@@ -3209,7 +3209,7 @@ void vTaskMissedYield( void )
 \r
                if( xTask != NULL )\r
                {\r
-                       pxTCB = ( TCB_t * ) xTask;\r
+                       pxTCB = xTask;\r
                        uxReturn = pxTCB->uxTaskNumber;\r
                }\r
                else\r
@@ -3231,7 +3231,7 @@ void vTaskMissedYield( void )
 \r
                if( xTask != NULL )\r
                {\r
-                       pxTCB = ( TCB_t * ) xTask;\r
+                       pxTCB = xTask;\r
                        pxTCB->uxTaskNumber = uxHandle;\r
                }\r
        }\r
@@ -4598,7 +4598,7 @@ TickType_t uxReturn;
        uint8_t ucOriginalNotifyState;\r
 \r
                configASSERT( xTaskToNotify );\r
-               pxTCB = ( TCB_t * ) xTaskToNotify;\r
+               pxTCB = xTaskToNotify;\r
 \r
                taskENTER_CRITICAL();\r
                {\r
@@ -4732,7 +4732,7 @@ TickType_t uxReturn;
                http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
                portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
 \r
-               pxTCB = ( TCB_t * ) xTaskToNotify;\r
+               pxTCB = xTaskToNotify;\r
 \r
                uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
                {\r
@@ -4860,7 +4860,7 @@ TickType_t uxReturn;
                http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
                portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
 \r
-               pxTCB = ( TCB_t * ) xTaskToNotify;\r
+               pxTCB = xTaskToNotify;\r
 \r
                uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
                {\r
index 10f08a18b7a5ccf4f261e928a18a1b4159591241..97e8786839e3c8b271380f8a2434df9ab11df543 100644 (file)
@@ -42,11 +42,11 @@ task.h is included from an application file. */
        #error configUSE_TIMERS must be set to 1 to make the xTimerPendFunctionCall() function available.\r
 #endif\r
 \r
-/* Lint e961 and e750 are suppressed as a MISRA exception justified because the\r
-MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the\r
-header files above, but not in this file, in order to generate the correct\r
-privileged Vs unprivileged linkage and placement. */\r
-#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */\r
+/* Lint e9021, e961 and e750 are suppressed as a MISRA exception justified\r
+because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined\r
+for the header files above, but not in this file, in order to generate the\r
+correct privileged Vs unprivileged linkage and placement. */\r
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e9021 !e961 !e750. */\r
 \r
 \r
 /* This entire source file will be skipped if the application is not configured\r
@@ -65,7 +65,7 @@ defining trmTIMER_SERVICE_TASK_NAME in FreeRTOSConfig.h. */
 #endif\r
 \r
 /* The definition of the timers themselves. */\r
-typedef struct tmrTimerControl\r
+typedef struct TimerDef_t\r
 {\r
        const char                              *pcTimerName;           /*<< Text name.  This is not used by the kernel, it is included simply to make debugging easier. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
        ListItem_t                              xTimerListItem;         /*<< Standard linked list item as used by all kernel features for event management. */\r
@@ -128,8 +128,6 @@ which static variables must be declared volatile. */
 /* The list in which active timers are stored.  Timers are referenced in expire\r
 time order, with the nearest expiry time at the front of the list.  Only the\r
 timer service task is allowed to access these lists. */\r
-PRIVILEGED_DATA static List_t xActiveTimerList1;\r
-PRIVILEGED_DATA static List_t xActiveTimerList2;\r
 PRIVILEGED_DATA static List_t *pxCurrentTimerList;\r
 PRIVILEGED_DATA static List_t *pxOverflowTimerList;\r
 \r
@@ -283,7 +281,7 @@ BaseType_t xReturn = pdFAIL;
        {\r
        Timer_t *pxNewTimer;\r
 \r
-               pxNewTimer = ( Timer_t * ) pvPortMalloc( sizeof( Timer_t ) );\r
+               pxNewTimer = ( Timer_t * ) pvPortMalloc( sizeof( Timer_t ) ); /*lint !e9087 !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack, and the first member of Timer_t is always a pointer to the timer's mame. */\r
 \r
                if( pxNewTimer != NULL )\r
                {\r
@@ -323,12 +321,13 @@ BaseType_t xReturn = pdFAIL;
                        structure. */\r
                        volatile size_t xSize = sizeof( StaticTimer_t );\r
                        configASSERT( xSize == sizeof( Timer_t ) );\r
+                       ( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */\r
                }\r
                #endif /* configASSERT_DEFINED */\r
 \r
                /* A pointer to a StaticTimer_t structure MUST be provided, use it. */\r
                configASSERT( pxTimerBuffer );\r
-               pxNewTimer = ( Timer_t * ) pxTimerBuffer; /*lint !e740 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */\r
+               pxNewTimer = ( Timer_t * ) pxTimerBuffer; /*lint !e740 !e9087 StaticTimer_t is a pointer to a Timer_t, so guaranteed to be aligned and sized correctly (checked by an assert()), so this is safe. */\r
 \r
                if( pxNewTimer != NULL )\r
                {\r
@@ -392,7 +391,7 @@ DaemonTaskMessage_t xMessage;
                /* Send a command to the timer service task to start the xTimer timer. */\r
                xMessage.xMessageID = xCommandID;\r
                xMessage.u.xTimerParameters.xMessageValue = xOptionalValue;\r
-               xMessage.u.xTimerParameters.pxTimer = ( Timer_t * ) xTimer;\r
+               xMessage.u.xTimerParameters.pxTimer = xTimer;\r
 \r
                if( xCommandID < tmrFIRST_FROM_ISR_COMMAND )\r
                {\r
@@ -432,7 +431,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void )
 \r
 TickType_t xTimerGetPeriod( TimerHandle_t xTimer )\r
 {\r
-Timer_t *pxTimer = ( Timer_t * ) xTimer;\r
+Timer_t *pxTimer = xTimer;\r
 \r
        configASSERT( xTimer );\r
        return pxTimer->xTimerPeriodInTicks;\r
@@ -441,7 +440,7 @@ Timer_t *pxTimer = ( Timer_t * ) xTimer;
 \r
 TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer )\r
 {\r
-Timer_t * pxTimer = ( Timer_t * ) xTimer;\r
+Timer_t * pxTimer =  xTimer;\r
 TickType_t xReturn;\r
 \r
        configASSERT( xTimer );\r
@@ -452,7 +451,7 @@ TickType_t xReturn;
 \r
 const char * pcTimerGetName( TimerHandle_t xTimer ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
 {\r
-Timer_t *pxTimer = ( Timer_t * ) xTimer;\r
+Timer_t *pxTimer = xTimer;\r
 \r
        configASSERT( xTimer );\r
        return pxTimer->pcTimerName;\r
@@ -462,7 +461,7 @@ Timer_t *pxTimer = ( Timer_t * ) xTimer;
 static void prvProcessExpiredTimer( const TickType_t xNextExpireTime, const TickType_t xTimeNow )\r
 {\r
 BaseType_t xResult;\r
-Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList );\r
+Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList ); /*lint !e9087 !e9079 void * is used as this macro is used with tasks and co-routines too.  Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */\r
 \r
        /* Remove the timer from the list of active timers.  A check has already\r
        been performed to ensure the list is not empty. */\r
@@ -848,7 +847,7 @@ BaseType_t xResult;
                xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList );\r
 \r
                /* Remove the timer from the list. */\r
-               pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList );\r
+               pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList ); /*lint !e9087 !e9079 void * is used as this macro is used with tasks and co-routines too.  Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */\r
                ( void ) uxListRemove( &( pxTimer->xTimerListItem ) );\r
                traceTIMER_EXPIRED( pxTimer );\r
 \r
@@ -893,6 +892,9 @@ BaseType_t xResult;
 \r
 static void prvCheckForValidListAndQueue( void )\r
 {\r
+PRIVILEGED_DATA static List_t xActiveTimerList1;\r
+PRIVILEGED_DATA static List_t xActiveTimerList2;\r
+\r
        /* Check that the list from which active timers are referenced, and the\r
        queue used to communicate with the timer service, have been\r
        initialised. */\r
@@ -945,7 +947,7 @@ static void prvCheckForValidListAndQueue( void )
 BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer )\r
 {\r
 BaseType_t xTimerIsInActiveList;\r
-Timer_t *pxTimer = ( Timer_t * ) xTimer;\r
+Timer_t *pxTimer = xTimer;\r
 \r
        configASSERT( xTimer );\r
 \r
@@ -955,7 +957,14 @@ Timer_t *pxTimer = ( Timer_t * ) xTimer;
                /* Checking to see if it is in the NULL list in effect checks to see if\r
                it is referenced from either the current or the overflow timer lists in\r
                one go, but the logic has to be reversed, hence the '!'. */\r
-               xTimerIsInActiveList = ( BaseType_t ) !( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) ); /*lint !e961. Cast is only redundant when NULL is passed into the macro. */\r
+               if( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) == pdTRUE )\r
+               {\r
+                       xTimerIsInActiveList = pdFALSE;\r
+               }\r
+               else\r
+               {\r
+                       xTimerIsInActiveList = pdTRUE;\r
+               }\r
        }\r
        taskEXIT_CRITICAL();\r
 \r
@@ -965,7 +974,7 @@ Timer_t *pxTimer = ( Timer_t * ) xTimer;
 \r
 void *pvTimerGetTimerID( const TimerHandle_t xTimer )\r
 {\r
-Timer_t * const pxTimer = ( Timer_t * ) xTimer;\r
+Timer_t * const pxTimer = xTimer;\r
 void *pvReturn;\r
 \r
        configASSERT( xTimer );\r
@@ -982,7 +991,7 @@ void *pvReturn;
 \r
 void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID )\r
 {\r
-Timer_t * const pxTimer = ( Timer_t * ) xTimer;\r
+Timer_t * const pxTimer = xTimer;\r
 \r
        configASSERT( xTimer );\r
 \r