From 88a73c434709f79abfdeecdba280e6421221013b Mon Sep 17 00:00:00 2001 From: Andreas Nordal <4992374+anordal@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:12:06 +0200 Subject: [PATCH] test_lTCPWindowTxAdd_nothing_to_do(): Fix TCP window initialization Under Gcc 11, this expression in the tested function lTCPWindowTxAdd() was always true, leading to imperfect coverage: pxSegment->lDataLength < pxSegment->lMaxLength With Gcc 13, they were both 0. Let's add zero-initialization to make this what's tested for. --- test/unit-test/FreeRTOS_TCP_WIN/FreeRTOS_TCP_WIN_utest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit-test/FreeRTOS_TCP_WIN/FreeRTOS_TCP_WIN_utest.c b/test/unit-test/FreeRTOS_TCP_WIN/FreeRTOS_TCP_WIN_utest.c index 7ccee7a03..99e800e41 100644 --- a/test/unit-test/FreeRTOS_TCP_WIN/FreeRTOS_TCP_WIN_utest.c +++ b/test/unit-test/FreeRTOS_TCP_WIN/FreeRTOS_TCP_WIN_utest.c @@ -1050,13 +1050,14 @@ void test_lTCPWindowTxAdd_nothing_to_do( void ) { int32_t lDone; TCPWindow_t xWindow = { 0 }; + TCPSegment_t xSegment = { 0 }; uint32_t ulLength = 0; int32_t lPosition = 0; int32_t lMax = 0; BaseType_t xBackup = xTCPWindowLoggingLevel; /* in real code, this points to a list of segments */ - xWindow.pxHeadSegment = malloc( sizeof( TCPSegment_t ) ); + xWindow.pxHeadSegment = &xSegment; xTCPWindowLoggingLevel = 3; @@ -1068,7 +1069,6 @@ void test_lTCPWindowTxAdd_nothing_to_do( void ) TEST_ASSERT_EQUAL( 0, lDone ); xTCPWindowLoggingLevel = xBackup; - free( xWindow.pxHeadSegment ); } void test_lTCPWindowTxAdd_null_txSegment( void )