Skip to content

Commit

Permalink
Use suffix "U" for unsigned constant (FreeRTOS#1041)
Browse files Browse the repository at this point in the history
* Fix the constant suffix to U

* Fix more unsigned contant suffix

---------

Co-authored-by: Ubuntu <[email protected]>
  • Loading branch information
chinglee-iot and Ubuntu authored Apr 19, 2024
1 parent fdf4695 commit c02a347
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 47 deletions.
24 changes: 12 additions & 12 deletions include/event_groups.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@
* item value. It is important they don't clash with the
* taskEVENT_LIST_ITEM_VALUE_IN_USE definition. */
#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint16_t ) 0x0100 )
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint16_t ) 0x0200 )
#define eventWAIT_FOR_ALL_BITS ( ( uint16_t ) 0x0400 )
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint16_t ) 0xff00 )
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint16_t ) 0x0100U )
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint16_t ) 0x0200U )
#define eventWAIT_FOR_ALL_BITS ( ( uint16_t ) 0x0400U )
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint16_t ) 0xff00U )
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint32_t ) 0x01000000 )
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint32_t ) 0x02000000 )
#define eventWAIT_FOR_ALL_BITS ( ( uint32_t ) 0x04000000 )
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint32_t ) 0xff000000 )
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint32_t ) 0x01000000U )
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint32_t ) 0x02000000U )
#define eventWAIT_FOR_ALL_BITS ( ( uint32_t ) 0x04000000U )
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint32_t ) 0xff000000U )
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_64_BITS )
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint64_t ) 0x0100000000000000 )
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint64_t ) 0x0200000000000000 )
#define eventWAIT_FOR_ALL_BITS ( ( uint64_t ) 0x0400000000000000 )
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint64_t ) 0xff00000000000000 )
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint64_t ) 0x0100000000000000U )
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint64_t ) 0x0200000000000000U )
#define eventWAIT_FOR_ALL_BITS ( ( uint64_t ) 0x0400000000000000U )
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint64_t ) 0xff00000000000000U )
#endif /* if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) */

/* *INDENT-OFF* */
Expand Down
8 changes: 4 additions & 4 deletions include/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t;
* char ucData[ 20 ];
* } xMessage;
*
* uint32_t ulVar = 10UL;
* uint32_t ulVar = 10U;
*
* void vATask( void *pvParameters )
* {
Expand Down Expand Up @@ -385,7 +385,7 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t;
* char ucData[ 20 ];
* } xMessage;
*
* uint32_t ulVar = 10UL;
* uint32_t ulVar = 10U;
*
* void vATask( void *pvParameters )
* {
Expand Down Expand Up @@ -470,7 +470,7 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t;
* char ucData[ 20 ];
* } xMessage;
*
* uint32_t ulVar = 10UL;
* uint32_t ulVar = 10U;
*
* void vATask( void *pvParameters )
* {
Expand Down Expand Up @@ -643,7 +643,7 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t;
* char ucData[ 20 ];
* } xMessage;
*
* uint32_t ulVar = 10UL;
* uint32_t ulVar = 10U;
*
* void vATask( void *pvParameters )
* {
Expand Down
26 changes: 13 additions & 13 deletions include/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@

/* MPU region parameters passed in ulParameters
* of MemoryRegion_t struct. */
#define tskMPU_REGION_READ_ONLY ( 1UL << 0UL )
#define tskMPU_REGION_READ_WRITE ( 1UL << 1UL )
#define tskMPU_REGION_EXECUTE_NEVER ( 1UL << 2UL )
#define tskMPU_REGION_NORMAL_MEMORY ( 1UL << 3UL )
#define tskMPU_REGION_DEVICE_MEMORY ( 1UL << 4UL )
#define tskMPU_REGION_READ_ONLY ( 1U << 0U )
#define tskMPU_REGION_READ_WRITE ( 1U << 1U )
#define tskMPU_REGION_EXECUTE_NEVER ( 1U << 2U )
#define tskMPU_REGION_NORMAL_MEMORY ( 1U << 3U )
#define tskMPU_REGION_DEVICE_MEMORY ( 1U << 4U )

/* MPU region permissions stored in MPU settings to
* authorize access requests. */
#define tskMPU_READ_PERMISSION ( 1UL << 0UL )
#define tskMPU_WRITE_PERMISSION ( 1UL << 1UL )
#define tskMPU_READ_PERMISSION ( 1U << 0U )
#define tskMPU_WRITE_PERMISSION ( 1U << 1U )

/* The direct to task notification feature used to have only a single notification
* per task. Now there is an array of notifications per task that is dimensioned by
Expand Down Expand Up @@ -473,7 +473,7 @@ typedef enum
* {
* // The parameter value is expected to be 1 as 1 is passed in the
* // pvParameters value in the call to xTaskCreateStatic().
* configASSERT( ( uint32_t ) pvParameters == 1UL );
* configASSERT( ( uint32_t ) pvParameters == 1U );
*
* for( ;; )
* {
Expand Down Expand Up @@ -564,7 +564,7 @@ typedef enum
* "ATask", // pcName - just a text name for the task to assist debugging.
* 100, // uxStackDepth - the stack size DEFINED IN WORDS.
* NULL, // pvParameters - passed into the task function as the function parameters.
* ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
* ( 1U | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
* cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
*
* // xRegions - Allocate up to three separate memory regions for access by
Expand Down Expand Up @@ -658,7 +658,7 @@ typedef enum
* "ATask", // pcName - just a text name for the task to assist debugging.
* 100, // uxStackDepth - the stack size DEFINED IN WORDS.
* NULL, // pvParameters - passed into the task function as the function parameters.
* ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
* ( 1U | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
* cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
*
* // xRegions - Allocate up to three separate memory regions for access by
Expand Down Expand Up @@ -2139,7 +2139,7 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION;
* uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );
*
* // For percentage calculations.
* ulTotalRunTime /= 100UL;
* ulTotalRunTime /= 100U;
*
* // Avoid divide by zero errors.
* if( ulTotalRunTime > 0 )
Expand All @@ -2153,7 +2153,7 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION;
* // ulTotalRunTimeDiv100 has already been divided by 100.
* ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;
*
* if( ulStatsAsPercentage > 0UL )
* if( ulStatsAsPercentage > 0U )
* {
* sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );
* }
Expand Down Expand Up @@ -2863,7 +2863,7 @@ BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify,
* will be cleared in the calling task's notification value before the task
* checks to see if any notifications are pending, and optionally blocks if no
* notifications are pending. Setting ulBitsToClearOnEntry to ULONG_MAX (if
* limits.h is included) or 0xffffffffUL (if limits.h is not included) will have
* limits.h is included) or 0xffffffffU (if limits.h is not included) will have
* the effect of resetting the task's notification value to 0. Setting
* ulBitsToClearOnEntry to 0 will leave the task's notification value unchanged.
*
Expand Down
6 changes: 3 additions & 3 deletions portable/template/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ typedef unsigned char UBaseType_t;

#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
typedef uint16_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffff
#define portMAX_DELAY ( TickType_t ) 0xffffU
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
typedef uint32_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
#define portMAX_DELAY ( TickType_t ) 0xffffffffU
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_64_BITS )
typedef uint64_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffffffffffffffff
#define portMAX_DELAY ( TickType_t ) 0xffffffffffffffffU
#else
#error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width.
#endif
Expand Down
30 changes: 15 additions & 15 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@
* responsibility of whichever module is using the value to ensure it gets set back
* to its original value when it is released. */
#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint16_t ) 0x8000 )
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint16_t ) 0x8000U )
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint32_t ) 0x80000000 )
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint32_t ) 0x80000000U )
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_64_BITS )
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint64_t ) 0x8000000000000000 )
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint64_t ) 0x8000000000000000U )
#endif

/* Indicates that the task is not actively running on any core. */
Expand All @@ -314,7 +314,7 @@
#endif

/* Indicates that the task is an Idle task. */
#define taskATTRIBUTE_IS_IDLE ( UBaseType_t ) ( 1UL << 0UL )
#define taskATTRIBUTE_IS_IDLE ( UBaseType_t ) ( 1U << 0U )

#if ( ( configNUMBER_OF_CORES > 1 ) && ( portCRITICAL_NESTING_IN_TCB == 1 ) )
#define portGET_CRITICAL_NESTING_COUNT() ( pxCurrentTCBs[ portGET_CORE_ID() ]->uxCriticalNesting )
Expand Down Expand Up @@ -1835,7 +1835,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
pxTopOfStack = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );

/* Check the alignment of the calculated top of stack is correct. */
configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );
configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0U ) );

#if ( configRECORD_STACK_HIGH_ADDRESS == 1 )
{
Expand All @@ -1851,7 +1851,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
pxTopOfStack = ( StackType_t * ) ( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) + portBYTE_ALIGNMENT_MASK ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );

/* Check the alignment of the calculated top of stack is correct. */
configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );
configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0U ) );

/* The other extreme of the stack space is required if stack checking is
* performed. */
Expand Down Expand Up @@ -2891,7 +2891,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,

/* Only reset the event list item value if the value is not
* being used for anything else. */
if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == ( ( TickType_t ) 0UL ) )
if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == ( ( TickType_t ) 0U ) )
{
listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxNewPriority ) );
}
Expand Down Expand Up @@ -6596,7 +6596,7 @@ static void prvResetNextTaskUnblockTime( void )
/* Adjust the mutex holder state to account for its new
* priority. Only reset the event list item value if the value is
* not being used for anything else. */
if( ( listGET_LIST_ITEM_VALUE( &( pxMutexHolderTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == ( ( TickType_t ) 0UL ) )
if( ( listGET_LIST_ITEM_VALUE( &( pxMutexHolderTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == ( ( TickType_t ) 0U ) )
{
listSET_LIST_ITEM_VALUE( &( pxMutexHolderTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxCurrentTCB->uxPriority );
}
Expand Down Expand Up @@ -6825,7 +6825,7 @@ static void prvResetNextTaskUnblockTime( void )

/* Only reset the event list item value if the value is not
* being used for anything else. */
if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == ( ( TickType_t ) 0UL ) )
if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == ( ( TickType_t ) 0U ) )
{
listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxPriorityToUse );
}
Expand Down Expand Up @@ -7440,10 +7440,10 @@ static void prvResetNextTaskUnblockTime( void )
uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalTime );

/* For percentage calculations. */
ulTotalTime /= ( ( configRUN_TIME_COUNTER_TYPE ) 100UL );
ulTotalTime /= ( ( configRUN_TIME_COUNTER_TYPE ) 100U );

/* Avoid divide by zero errors. */
if( ulTotalTime > 0UL )
if( ulTotalTime > 0U )
{
/* Create a human readable table from the binary data. */
for( x = 0; x < uxArraySize; x++ )
Expand All @@ -7469,7 +7469,7 @@ static void prvResetNextTaskUnblockTime( void )
* character. */
if( uxConsumedBufferLength < ( uxBufferLength - 1U ) )
{
if( ulStatsAsPercentage > 0UL )
if( ulStatsAsPercentage > 0U )
{
#ifdef portLU_PRINTF_SPECIFIER_REQUIRED
{
Expand Down Expand Up @@ -7633,7 +7633,7 @@ TickType_t uxTaskResetEventItemValue( void )
taskENTER_CRITICAL();
{
/* Only block if the notification count is not already non-zero. */
if( pxCurrentTCB->ulNotifiedValue[ uxIndexToWaitOn ] == 0UL )
if( pxCurrentTCB->ulNotifiedValue[ uxIndexToWaitOn ] == 0U )
{
/* Mark this task as waiting for a notification. */
pxCurrentTCB->ucNotifyState[ uxIndexToWaitOn ] = taskWAITING_NOTIFICATION;
Expand Down Expand Up @@ -7684,11 +7684,11 @@ TickType_t uxTaskResetEventItemValue( void )
traceTASK_NOTIFY_TAKE( uxIndexToWaitOn );
ulReturn = pxCurrentTCB->ulNotifiedValue[ uxIndexToWaitOn ];

if( ulReturn != 0UL )
if( ulReturn != 0U )
{
if( xClearCountOnExit != pdFALSE )
{
pxCurrentTCB->ulNotifiedValue[ uxIndexToWaitOn ] = ( uint32_t ) 0UL;
pxCurrentTCB->ulNotifiedValue[ uxIndexToWaitOn ] = ( uint32_t ) 0U;
}
else
{
Expand Down

0 comments on commit c02a347

Please sign in to comment.