Skip to content

Commit

Permalink
Feature/fixing clang gnu compiler warnings (#620)
Browse files Browse the repository at this point in the history
* Adding in ability to support a library for freertos_config and a custom freertos_kernel_port (#558)

* Using single name definition for libraries everywhere. (#558)

* Supporting backwards compatibility with FREERTOS_CONFIG_FILE_DIRECTORY (#571)

* Removing compiler warnings for GNU and Clang. (#571)

* Added in documentation on how to consume from a main project. Added default PORT selection for native POSIX and MINGW platforms.

* Only adding freertos_config if it exists. Removing auto generation of it from a FREERTOS_CONFIG_FILE_DIRECTORY.

* Fixing clang and gnu compiler warnings.

* Adding in project information and how to compile for GNU/clang

* Fixing compiler issue with unused variable - no need to declare variable.

* Adding in compile warnings for linux builds that kernel is okay with using.

* Fixing more extra-semi-stmt clang warnings.

* Moving definition of hooks into header files if features are enabled.

* Fixing formatting with uncrustify.

* Fixing merge conflicts with main merge.

* Fixing compiler errors due to merge issues and formatting.

* Fixing Line feeds.

* Adding 'portNORETURN' into portmacros.h. Other Updates based on PR request

* Further clean-up of clang and clang-tidy issues.

* Removing compiler specific pragmas from common c files.

* Fixing missing lexicon entry and uncrustify formatting changes.

* Resolving merge issue multiple defnitions of proto for prvIdleTask

* Fixing formatting issues that are not covered by uncrustify. Use clang-tidy instead if you want this level of control.

* More uncrustify formatting issues.

* Fixing extra bracket in #if statement.

---------

Co-authored-by: Gaurav-Aggarwal-AWS <[email protected]>
  • Loading branch information
phelter and aggarg authored Feb 23, 2023
1 parent 5d05601 commit 8cd5451
Show file tree
Hide file tree
Showing 38 changed files with 260 additions and 172 deletions.
1 change: 1 addition & 0 deletions .github/lexicon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,7 @@ vaninterruptserviceroutine
vanisr
vanothertask
vapplicationcleartimerinterrupt
vapplicationdaemontaskstartuphook
vapplicationexceptionregisterdump
vapplicationfpusafeirqhandler
vapplicationgetidletaskmemory
Expand Down
41 changes: 41 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,47 @@ elseif((FREERTOS_PORT STREQUAL "A_CUSTOM_PORT") AND (NOT TARGET freertos_kernel_
" freertos_kernel)")
endif()

########################################################################
# Requirements
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)

########################################################################
# Overall Compile Options
# Note the compile option strategy is to error on everything and then
# Per library opt-out of things that are warnings/errors.
# This ensures that no matter what strategy for compilation you take, the
# builds will still occur.
#
# Only tested with GNU and Clang.
# Other options are https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_%3CLANG%3E_COMPILER_ID
# Naming of compilers translation map:
#
# FreeRTOS | CMake
# -------------------
# CCS | ?TBD?
# GCC | GNU, Clang, *Clang Others?
# IAR | IAR
# Keil | ARMCC
# MSVC | MSVC # Note only for MinGW?
# Renesas | ?TBD?

add_compile_options(
### Gnu/Clang C Options
$<$<COMPILE_LANG_AND_ID:C,GNU>:-fdiagnostics-color=always>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-fcolor-diagnostics>

$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wall>
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wextra>
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wpedantic>
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Werror>

This comment has been minimized.

Copy link
@RodrigoDornelles

RodrigoDornelles Feb 23, 2023

this line must be related with issue #632

$<$<COMPILE_LANG_AND_ID:C,Clang>:-Weverything>

# TODO: Add in other Compilers here.
)


########################################################################
add_subdirectory(portable)

add_library(freertos_kernel STATIC
Expand Down
10 changes: 5 additions & 5 deletions event_groups.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@
typedef struct EventGroupDef_t
{
EventBits_t uxEventBits;
List_t xTasksWaitingForBits; /*< List of tasks waiting for a bit to be set. */
List_t xTasksWaitingForBits; /**< List of tasks waiting for a bit to be set. */

#if ( configUSE_TRACE_FACILITY == 1 )
UBaseType_t uxEventGroupNumber;
#endif

#if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the event group is statically allocated to ensure no attempt is made to free the memory. */
uint8_t ucStaticallyAllocated; /**< Set to pdTRUE if the event group is statically allocated to ensure no attempt is made to free the memory. */
#endif
} EventGroup_t;

Expand Down Expand Up @@ -521,15 +521,15 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup,

EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup )
{
UBaseType_t uxSavedInterruptStatus;
portBASE_TYPE xSavedInterruptStatus;
EventGroup_t const * const pxEventBits = xEventGroup;
EventBits_t uxReturn;

uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
xSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
{
uxReturn = pxEventBits->uxEventBits;
}
portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );
portCLEAR_INTERRUPT_MASK_FROM_ISR( xSavedInterruptStatus );

return uxReturn;
} /*lint !e818 EventGroupHandle_t is a typedef used in other functions to so can't be pointer to const. */
Expand Down
4 changes: 4 additions & 0 deletions include/FreeRTOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,10 @@
#define portDONT_DISCARD
#endif

#ifndef portNORETURN
#define portNORETURN
#endif

#ifndef configUSE_TIME_SLICING
#define configUSE_TIME_SLICING 1
#endif
Expand Down
36 changes: 18 additions & 18 deletions include/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,20 @@
struct xLIST;
struct xLIST_ITEM
{
listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in ascending order. */
struct xLIST_ITEM * configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */
struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */
void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */
struct xLIST * configLIST_VOLATILE pxContainer; /*< Pointer to the list in which this list item is placed (if any). */
listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /**< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
configLIST_VOLATILE TickType_t xItemValue; /**< The value being listed. In most cases this is used to sort the list in ascending order. */
struct xLIST_ITEM * configLIST_VOLATILE pxNext; /**< Pointer to the next ListItem_t in the list. */
struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /**< Pointer to the previous ListItem_t in the list. */
void * pvOwner; /**< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */
struct xLIST * configLIST_VOLATILE pxContainer; /**< Pointer to the list in which this list item is placed (if any). */
listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /**< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
};
typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */

#if ( configUSE_MINI_LIST_ITEM == 1 )
struct xMINI_LIST_ITEM
{
listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /**< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
configLIST_VOLATILE TickType_t xItemValue;
struct xLIST_ITEM * configLIST_VOLATILE pxNext;
struct xLIST_ITEM * configLIST_VOLATILE pxPrevious;
Expand All @@ -171,11 +171,11 @@ typedef struct xLIST_ITEM ListItem_t; /* For some reason lint
*/
typedef struct xLIST
{
listFIRST_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
listFIRST_LIST_INTEGRITY_CHECK_VALUE /**< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
volatile UBaseType_t uxNumberOfItems;
ListItem_t * configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */
MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */
listSECOND_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
ListItem_t * configLIST_VOLATILE pxIndex; /**< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */
MiniListItem_t xListEnd; /**< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */
listSECOND_LIST_INTEGRITY_CHECK_VALUE /**< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
} List_t;

/*
Expand Down Expand Up @@ -283,7 +283,7 @@ typedef struct xLIST
* \ingroup LinkedList
*/
#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \
{ \
do { \
List_t * const pxConstList = ( pxList ); \
/* Increment the index to the next item and return the item, ensuring */ \
/* we don't return the marker used at the end of the list. */ \
Expand All @@ -293,7 +293,7 @@ typedef struct xLIST
( pxConstList )->pxIndex = ( pxConstList )->xListEnd.pxNext; \
} \
( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \
}
} while( 0 )

/*
* Version of uxListRemove() that does not return a value. Provided as a slight
Expand All @@ -312,7 +312,7 @@ typedef struct xLIST
* \ingroup LinkedList
*/
#define listREMOVE_ITEM( pxItemToRemove ) \
{ \
do { \
/* The list item knows which list it is in. Obtain the list from the list \
* item. */ \
List_t * const pxList = ( pxItemToRemove )->pxContainer; \
Expand All @@ -327,7 +327,7 @@ typedef struct xLIST
\
( pxItemToRemove )->pxContainer = NULL; \
( pxList->uxNumberOfItems )--; \
}
} while( 0 )

/*
* Inline version of vListInsertEnd() to provide slight optimisation for
Expand All @@ -352,7 +352,7 @@ typedef struct xLIST
* \ingroup LinkedList
*/
#define listINSERT_END( pxList, pxNewListItem ) \
{ \
do { \
ListItem_t * const pxIndex = ( pxList )->pxIndex; \
\
/* Only effective when configASSERT() is also defined, these tests may catch \
Expand All @@ -374,7 +374,7 @@ typedef struct xLIST
( pxNewListItem )->pxContainer = ( pxList ); \
\
( ( pxList )->uxNumberOfItems )++; \
}
} while( 0 )

/*
* Access function to obtain the owner of the first entry in a list. Lists
Expand Down
6 changes: 3 additions & 3 deletions include/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -1346,9 +1346,9 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,
* @param pvBuffer Pointer to the buffer into which the received item will
* be copied.
*
* @param pxTaskWoken A task may be blocked waiting for space to become
* available on the queue. If xQueueReceiveFromISR causes such a task to
* unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will
* @param pxHigherPriorityTaskWoken A task may be blocked waiting for space to
* become available on the queue. If xQueueReceiveFromISR causes such a task
* to unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will
* remain unchanged.
*
* @return pdTRUE if an item was successfully received from the queue,
Expand Down
4 changes: 2 additions & 2 deletions include/stack_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) )

#define taskCHECK_FOR_STACK_OVERFLOW() \
{ \
do { \
const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \
const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \
\
Expand All @@ -98,7 +98,7 @@
{ \
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
} \
}
} while( 0 )

#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
/*-----------------------------------------------------------*/
Expand Down
4 changes: 2 additions & 2 deletions include/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ typedef enum
*
* @param xTask The handle of the task being updated.
*
* @param xRegions A pointer to a MemoryRegion_t structure that contains the
* @param[in] pxRegions A pointer to a MemoryRegion_t structure that contains the
* new memory region definitions.
*
* Example usage:
Expand Down Expand Up @@ -1667,7 +1667,7 @@ configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVIL
#endif


#if ( configUSE_TICK_HOOK > 0 )
#if ( configUSE_TICK_HOOK != 0 )

/**
* task.h
Expand Down
14 changes: 14 additions & 0 deletions include/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,20 @@ BaseType_t xTimerGenericCommand( TimerHandle_t xTimer,

#endif

#if ( configUSE_DAEMON_TASK_STARTUP_HOOK != 0 )

/**
* timers.h
* @code{c}
* void vApplicationDaemonTaskStartupHook( void );
* @endcode
*
* This hook function is called form the timer task once when the task starts running.
*/
void vApplicationDaemonTaskStartupHook( void );

#endif

/* *INDENT-OFF* */
#ifdef __cplusplus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
*/
#define portARCH_NAME "Cortex-M23"
#define portDONT_DISCARD __attribute__( ( used ) )
#define portNORETURN __attribute__( ( noreturn ) )
/*-----------------------------------------------------------*/

#if( configTOTAL_MPU_REGIONS == 16 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
*/
#define portARCH_NAME "Cortex-M23"
#define portDONT_DISCARD __attribute__( ( used ) )
#define portNORETURN __attribute__( ( noreturn ) )
/*-----------------------------------------------------------*/

#if( configTOTAL_MPU_REGIONS == 16 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
*/
#define portARCH_NAME "Cortex-M33"
#define portDONT_DISCARD __attribute__( ( used ) )
#define portNORETURN __attribute__( ( noreturn ) )
/*-----------------------------------------------------------*/

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
*/
#define portARCH_NAME "Cortex-M33"
#define portDONT_DISCARD __attribute__( ( used ) )
#define portNORETURN __attribute__( ( noreturn ) )
/*-----------------------------------------------------------*/

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
*/
#define portARCH_NAME "Cortex-M55"
#define portDONT_DISCARD __attribute__( ( used ) )
#define portNORETURN __attribute__( ( noreturn ) )
/*-----------------------------------------------------------*/

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
*/
#define portARCH_NAME "Cortex-M85"
#define portDONT_DISCARD __attribute__( ( used ) )
#define portNORETURN __attribute__( ( noreturn ) )
/*-----------------------------------------------------------*/

/**
Expand Down
1 change: 1 addition & 0 deletions portable/GCC/ARM_CM0/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
#define portBYTE_ALIGNMENT 8
#define portDONT_DISCARD __attribute__( ( used ) )
#define portNORETURN __attribute__( ( noreturn ) )
/*-----------------------------------------------------------*/


Expand Down
1 change: 1 addition & 0 deletions portable/GCC/ARM_CM23/non_secure/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
*/
#define portARCH_NAME "Cortex-M23"
#define portDONT_DISCARD __attribute__( ( used ) )
#define portNORETURN __attribute__( ( noreturn ) )
/*-----------------------------------------------------------*/

#if( configTOTAL_MPU_REGIONS == 16 )
Expand Down
1 change: 1 addition & 0 deletions portable/GCC/ARM_CM23_NTZ/non_secure/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
*/
#define portARCH_NAME "Cortex-M23"
#define portDONT_DISCARD __attribute__( ( used ) )
#define portNORETURN __attribute__( ( noreturn ) )
/*-----------------------------------------------------------*/

#if( configTOTAL_MPU_REGIONS == 16 )
Expand Down
1 change: 1 addition & 0 deletions portable/GCC/ARM_CM3/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
#define portBYTE_ALIGNMENT 8
#define portDONT_DISCARD __attribute__( ( used ) )
#define portNORETURN __attribute__( ( noreturn ) )
/*-----------------------------------------------------------*/

/* Scheduler utilities. */
Expand Down
1 change: 1 addition & 0 deletions portable/GCC/ARM_CM33/non_secure/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
*/
#define portARCH_NAME "Cortex-M33"
#define portDONT_DISCARD __attribute__( ( used ) )
#define portNORETURN __attribute__( ( noreturn ) )
/*-----------------------------------------------------------*/

/**
Expand Down
1 change: 1 addition & 0 deletions portable/GCC/ARM_CM33_NTZ/non_secure/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
*/
#define portARCH_NAME "Cortex-M33"
#define portDONT_DISCARD __attribute__( ( used ) )
#define portNORETURN __attribute__( ( noreturn ) )
/*-----------------------------------------------------------*/

/**
Expand Down
1 change: 1 addition & 0 deletions portable/GCC/ARM_CM3_MPU/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
#define portBYTE_ALIGNMENT 8
#define portDONT_DISCARD __attribute__( ( used ) )
#define portNORETURN __attribute__( ( noreturn ) )
/*-----------------------------------------------------------*/

/* SVC numbers for various services. */
Expand Down
1 change: 1 addition & 0 deletions portable/GCC/ARM_CM4F/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
#define portBYTE_ALIGNMENT 8
#define portDONT_DISCARD __attribute__( ( used ) )
#define portNORETURN __attribute__( ( noreturn ) )
/*-----------------------------------------------------------*/

/* Scheduler utilities. */
Expand Down
1 change: 1 addition & 0 deletions portable/GCC/ARM_CM4_MPU/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ typedef struct MPU_SETTINGS
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
#define portBYTE_ALIGNMENT 8
#define portDONT_DISCARD __attribute__( ( used ) )
#define portNORETURN __attribute__( ( noreturn ) )
/*-----------------------------------------------------------*/

/* SVC numbers for various services. */
Expand Down
1 change: 1 addition & 0 deletions portable/GCC/ARM_CM55/non_secure/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
*/
#define portARCH_NAME "Cortex-M55"
#define portDONT_DISCARD __attribute__( ( used ) )
#define portNORETURN __attribute__( ( noreturn ) )
/*-----------------------------------------------------------*/

/**
Expand Down
Loading

0 comments on commit 8cd5451

Please sign in to comment.