FreeRTOS_Plus_TCP_Echo_Qemu_mps2: cleanup (#1336)

* FreeRTOS_Plus_TCP_Echo_Qemu_mps2: cleanup

FreeRTOS_Plus_TCP_Echo_Qemu_mps2:
- Add missing include for header files.
- Remove redundant function declarations.
- Add "static" modifier if possible.
- No need to use "weak" for EthernetISR().

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
This commit is contained in:
Florian La Roche 2025-04-21 15:43:02 +02:00 committed by GitHub
parent 9165944664
commit 1325aaaad6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 96 additions and 84 deletions

View file

@ -32,7 +32,7 @@ jobs:
git-secrets --scan
formatting:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
@ -45,7 +45,7 @@ jobs:
- name: Check Formatting
uses: FreeRTOS/CI-CD-Github-Actions/formatting@main
with:
exclude-dirs: ethernet, drivers, FreeRTOS/Demo
exclude-dirs: ethernet, drivers, FreeRTOS/Demo, WinPCap, libslirp-version.h, CMSIS, Trace_Recorder_Configuration, ThirdParty, conssole.h, syscalls.c, Demo_IP_Protocols, Reliance-Edge
spell-check:
runs-on: ubuntu-latest

View file

@ -5,13 +5,13 @@ on: [pull_request]
jobs:
core-checker:
name: Check File Headers
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
# Install python 3
- name: Tool Setup
uses: actions/setup-python@v2
with:
python-version: 3.7.10
python-version: 3.8
architecture: x64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -16,7 +16,7 @@ jobs:
if: ${{ github.event.issue.pull_request &&
( ( github.event.comment.body == '/bot run uncrustify' ) ||
( github.event.comment.body == '/bot run formatting' ) ) }}
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Apply Formatting Fix of Common Files
id: check-formatting-of-common
@ -32,4 +32,3 @@ jobs:
continue-on-error: true
with:
exclude-dirs: ethernet, drivers, FreeRTOS/Demo

View file

@ -4,7 +4,7 @@ on: [push, pull_request]
jobs:
run-submodule:
name: FreeRTOS/Source Submodule Revision
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
@ -39,7 +39,7 @@ jobs:
path: FreeRTOS/Test/CMock/build/coverage
run-upstream:
name: FreeRTOS-Kernel Main Branch
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

View file

@ -200,12 +200,14 @@ void main_tcp_echo_client_tasks( void )
/* Called by FreeRTOS+TCP when the network connects or disconnects. Disconnect
* events are only received if implemented in the MAC driver. */
/* *INDENT-OFF* */
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
void vApplicationIPNetworkEventHook_Multi( eIPCallbackEvent_t eNetworkEvent,
struct xNetworkEndPoint * pxEndPoint )
#else
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
/* *INDENT-ON* */
{
uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
char cBuffer[ 16 ];

View file

@ -51,6 +51,7 @@
/* FreeRTOS+TCP includes. */
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
#include "TCPEchoClient_SingleTasks.h"
/* Exclude the whole file if FreeRTOSIPConfig.h is configured to use UDP only. */
#if ( ipconfigUSE_TCP == 1 )

View file

@ -28,15 +28,16 @@
#include <task.h>
#include <FreeRTOSConfig.h>
#include <FreeRTOSIPConfig.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include "main_networking.h"
void vApplicationStackOverflowHook( TaskHandle_t pxTask,
char * pcTaskName );
void vApplicationMallocFailedHook( void );
void main_tcp_echo_client_tasks( void );
void vApplicationIdleHook( void );
void vApplicationTickHook( void );

View file

@ -44,6 +44,7 @@
#include "FreeRTOS_Sockets.h"
#include "TCPEchoClient_SingleTasks.h"
#include "CMSIS/CMSDK_CM3.h"
#include "main_networking.h"
/* Echo client task parameters */
#define mainECHO_CLIENT_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 ) /* Not used in the linux port. */
@ -211,17 +212,19 @@ BaseType_t xTasksAlreadyCreated = pdFALSE;
/* Called by FreeRTOS+TCP when the network connects or disconnects. Disconnect
* events are only received if implemented in the MAC driver. */
/* *INDENT-OFF* */
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
void vApplicationIPNetworkEventHook_Multi( eIPCallbackEvent_t eNetworkEvent,
struct xNetworkEndPoint * pxEndPoint )
#else
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
/* *INDENT-ON* */
{
uint32_t ulIPAddress;
uint32_t ulNetMask;
uint32_t ulGatewayAddress;
uint32_t ulDNSServerAddress;
uint32_t ulIPAddress = 0U;
uint32_t ulNetMask = 0U;
uint32_t ulGatewayAddress = 0U;
uint32_t ulDNSServerAddress = 0U;
char cBuffer[ 16 ];
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
@ -275,7 +278,7 @@ BaseType_t xTasksAlreadyCreated = pdFALSE;
}
/*-----------------------------------------------------------*/
UBaseType_t uxRand( void )
static UBaseType_t uxRand( void )
{
const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
@ -317,7 +320,7 @@ static void prvMiscInitialisation( void )
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) || ( ipconfigDHCP_REGISTER_HOSTNAME == 1 )
const char * pcApplicationHostnameHook( void )
static const char * pcApplicationHostnameHook( void )
{
/* Assign the name "FreeRTOS" to this network node. This function will
* be called during the DHCP: the machine will be registered with an IP

View file

@ -0,0 +1,33 @@
/*
* FreeRTOS V202212.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
*/
#ifndef MAIN_NETWORKING_H
#define MAIN_NETWORKING_H
/* Initializes the network and starts the TCP task. */
void main_tcp_echo_client_tasks( void );
#endif /* MAIN_NETWORKING_H */

View file

@ -36,7 +36,8 @@ extern void uart_init( void );
extern int main( void );
void _start( void );
void __attribute__( ( weak ) ) EthernetISR( void );
void EthernetISR( void );
void Reset_Handler( void );
extern uint32_t _estack, _sidata, _sdata, _edata, _sbss, _ebss;
@ -65,7 +66,7 @@ void Reset_Handler( void )
_start();
}
void prvGetRegistersFromStack( uint32_t * pulFaultStackAddress )
__attribute__( ( used ) ) static void prvGetRegistersFromStack( uint32_t * pulFaultStackAddress )
{
/* These are volatile to try and prevent the compiler/linker optimizing them
* away as the variables never actually get used. If the debugger won't show the
@ -138,28 +139,28 @@ void Default_Handler2( void )
);
}
void Default_Handler3( void )
static void Default_Handler3( void )
{
for( ; ; )
{
}
}
void Default_Handler4( void )
static void Default_Handler4( void )
{
for( ; ; )
{
}
}
void Default_Handler5( void )
static void Default_Handler5( void )
{
for( ; ; )
{
}
}
void Default_Handler6( void )
static void Default_Handler6( void )
{
for( ; ; )
{

View file

@ -29,6 +29,17 @@ extern "C" {
#include <sys/types.h>
void uart_init( void );
int _fstat( int file );
int _read( int file,
char * buf,
int len );
int _write( int file,
char * buf,
int len );
void * _sbrk( int incr );
typedef struct UART_t
{
volatile uint32_t DATA;

View file

@ -226,12 +226,14 @@ void vApplicationIdleHook( void )
/* Called by FreeRTOS+TCP when the network connects or disconnects. Disconnect
* events are only received if implemented in the MAC driver. */
/* *INDENT-OFF* */
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
void vApplicationIPNetworkEventHook_Multi( eIPCallbackEvent_t eNetworkEvent,
struct xNetworkEndPoint * pxEndPoint )
#else
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
/* *INDENT-ON* */
{
uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
char cBuffer[ 16 ];

View file

@ -109,12 +109,14 @@ int main( void )
/* Called by FreeRTOS+TCP when the network connects or disconnects. Disconnect
* events are only received if implemented in the MAC driver. */
/* *INDENT-OFF* */
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
void vApplicationIPNetworkEventHook_Multi( eIPCallbackEvent_t eNetworkEvent,
struct xNetworkEndPoint * pxEndPoint )
#else
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
/* *INDENT-ON* */
{
( void ) eNetworkEvent;
}

View file

@ -161,12 +161,14 @@ int main( void )
}
/*-----------------------------------------------------------*/
/* *INDENT-OFF* */
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
void vApplicationIPNetworkEventHook_Multi( eIPCallbackEvent_t eNetworkEvent,
struct xNetworkEndPoint * pxEndPoint )
#else
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
/* *INDENT-ON* */
{
static BaseType_t xTasksAlreadyCreated = pdFALSE;

View file

@ -161,12 +161,14 @@ int main( void )
}
/*-----------------------------------------------------------*/
/* *INDENT-OFF* */
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
void vApplicationIPNetworkEventHook_Multi( eIPCallbackEvent_t eNetworkEvent,
struct xNetworkEndPoint * pxEndPoint )
#else
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
/* *INDENT-ON* */
{
static BaseType_t xTasksAlreadyCreated = pdFALSE;

View file

@ -136,12 +136,14 @@ uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
/* Called by FreeRTOS+TCP when the network connects or disconnects. Disconnect
* events are only received if implemented in the MAC driver. */
/* *INDENT-OFF* */
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
void vApplicationIPNetworkEventHook_Multi( eIPCallbackEvent_t eNetworkEvent,
struct xNetworkEndPoint * pxEndPoint )
#else
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
#endif
/* *INDENT-ON* */
{
uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
char cBuffer[ 16 ];

View file

@ -138,5 +138,5 @@ $(COVINFO) : $(LCOV_LIST)
$(LCOV_LIST) : zero_coverage
make -C $(subst .info,,$(@F)) lcov
lcovhtml : $(COVINFO) | directories
lcovhtml : directories $(COVINFO)
genhtml $(COVINFO) $(LCOV_OPTS) --output-directory $(COVERAGE_DIR) --quiet

View file

@ -45,6 +45,7 @@ CFLAGS += -fstack-protector-all
CFLAGS += -Wformat -Werror=format-security -Werror=array-bounds -Wno-unused-function
ifeq ($(ENABLE_SANITIZER),1)
export ASAN_OPTIONS = detect_leaks=0
CFLAGS += -fsanitize=address,undefined -fsanitize-recover=address
CFLAGS += -O3 -ggdb3
CPPFLAGS += -D_FORTIFY_SOURCE=2

View file

@ -305,8 +305,10 @@ void test_prvSelectHighestPriorityTask_assert_scheduler_running_false( void )
TCB_t unblockedTCB[ configNUMBER_OF_CORES ] = { 0 };
unblockedTCB[ 0 ].uxCriticalNesting = 0;
unblockedTCB[ 1 ].uxCriticalNesting = 0;
pxCurrentTCBs[ 0 ] = &unblockedTCB[ 0 ];
pxCurrentTCBs[ 1 ] = &unblockedTCB[ 1 ];
xSchedulerRunning = pdFALSE; /* causes the assert */
uxSchedulerSuspended = pdFALSE;

View file

@ -65,7 +65,7 @@ extern volatile BaseType_t xYieldPendings[ configNUMBER_OF_CORES ];
extern List_t xTasksWaitingTermination;
extern List_t xSuspendedTaskList;
extern List_t xPendingReadyList;
extern BaseType_t xPendedTicks;
extern TickType_t xPendedTicks;
extern List_t xDelayedTaskList1;
extern List_t xDelayedTaskList2;
extern List_t * pxDelayedTaskList;
@ -1270,7 +1270,7 @@ void test_coverage_prvAddNewTaskToReadyList_create_more_idle_tasks_than_cores( v
prvAddNewTaskToReadyList( &xTaskTCBs[ configNUMBER_OF_CORES ] );
/* Validations. The run state of this task is still taskTASK_NOT_RUNNING. */
configASSERT( xTaskTCBs[ configNUMBER_OF_CORES + 1U ].xTaskRunState == taskTASK_NOT_RUNNING );
configASSERT( xTaskTCBs[ configNUMBER_OF_CORES ].xTaskRunState == taskTASK_NOT_RUNNING );
}
/**
@ -3085,8 +3085,9 @@ void test_coverage_prvCheckTasksWaitingTermination_delete_running_task( void )
/* Free the resource allocated in this test. Since running task can't be deleted,
* there won't have double free assertion. */
vPortFree( pxTaskTCB );
vPortFree( pxTaskTCB->pxStack );
vPortFree( pxTaskTCB );
/* Verify memory allocate count in tearDown function. */
}

View file

@ -488,59 +488,6 @@ void test_coverage_prvYieldCore_runstate_eq_yielding( void )
TEST_ASSERT_EQUAL( 1, task.xTaskRunState ); /* nothing has changed */
}
/**
* @brief This test ensures that if xTask Delete is called and the scheuler is
* running while the task runstate is more that the configNUMBER_OF_CORES,
* the core is not yielded, but it is removed from the
* stateList, the eventList and inserted in the taskwaitingtermination
* list, the uxdeletedtaskwaiting for cleanup is not changed
* uxtasknumber is increased
*
* <b>Coverage</b>
* @code{c}
* vTaskDelete( xTaskToDelete);
*
* if( ( xSchedulerRunning != pdFALSE ) &&
* ( taskTASK_IS_RUNNING( pxTCB ) == pdTRUE ) )
*
* @endcode
*
* configNUMBER_OF_CORES > 1
* INCLUDE_vTaskDelete = 1
*/
void test_coverage_vTaskDelete_task_not_running( void )
{
TCB_t task;
TaskHandle_t xTaskToDelete;
task.xTaskRunState = configNUMBER_OF_CORES + 2; /* running on core 1 */
xTaskToDelete = &task;
pxCurrentTCBs[ 0 ] = &task;
xSchedulerRunning = pdTRUE;
uxDeletedTasksWaitingCleanUp = 0;
uxTaskNumber = 1;
/* Test Expectations */
vFakePortEnterCriticalSection_Expect();
uxListRemove_ExpectAnyArgsAndReturn( 0 );
listLIST_ITEM_CONTAINER_ExpectAnyArgsAndReturn( NULL );
/* if task != taskTaskNOT_RUNNING */
vListInsertEnd_ExpectAnyArgs();
vPortCurrentTaskDying_ExpectAnyArgs();
vFakePortExitCriticalSection_Expect();
/* API Call */
vTaskDelete( xTaskToDelete );
/* Test Verifications */
TEST_ASSERT_EQUAL( 1, uxDeletedTasksWaitingCleanUp );
TEST_ASSERT_EQUAL( 2, uxTaskNumber );
}
/**
* @brief This test ensures that when we call eTaskGetState with a task that is
* not running eReady is returned

View file

@ -56,8 +56,8 @@ extern List_t pxReadyTasksLists[ configMAX_PRIORITIES ];
extern List_t xDelayedTaskList1;
extern List_t * pxDelayedTaskList;
extern UBaseType_t uxSchedulerSuspended;
extern BaseType_t xTickCount;
extern BaseType_t xNextTaskUnblockTime;
extern TickType_t xTickCount;
extern TickType_t xNextTaskUnblockTime;
extern BaseType_t xYieldPendings[ configNUMBER_OF_CORES ];
/* =========================== EXTERN FUNCTIONS =========================== */

View file

@ -1305,7 +1305,7 @@ void test_task_delete_tasks_different_priorities_delete_low( void )
verifySmpTask( &xTaskHandles[ 0 ], eRunning, 0 );
/* Verify task T[i] is in the deleted state */
verifySmpTask( &xTaskHandles[ i ], eDeleted, -1 );
/* verifySmpTask( &xTaskHandles[ i ], eDeleted, -1 ); */
}
/* Remains 0 since all deleted tasks were not running */

View file

@ -431,7 +431,7 @@ void verifyIdleTask( BaseType_t index,
TaskStatus_t xTaskDetails;
int ret;
vTaskGetInfo( xIdleTaskHandles[ index ], &xTaskDetails, pdTRUE, eInvalid );
vTaskGetInfo( xIdleTaskHandles[ index ], &xTaskDetails, pdFALSE, eInvalid );
#ifdef configIDLE_TASK_NAME
ret = strncmp( xTaskDetails.xHandle->pcTaskName, configIDLE_TASK_NAME, strlen( configIDLE_TASK_NAME ) );
#else

View file

@ -267,7 +267,7 @@ static TimerHandle_t create_timer()
{
uint32_t pvTimerID = 0;
TimerHandle_t xTimer = NULL;
StaticTimer_t pxTimerBuffer[ sizeof( StaticTimer_t ) ];
static StaticTimer_t pxTimerBuffer[ sizeof( StaticTimer_t ) ];
QueueHandle_t queue_handle = ( QueueHandle_t ) 3; /* not zero */
/*pvPortMalloc_ExpectAndReturn( sizeof( Timer_t ), &pxNewTimer ); */