Skip to content

Commit ce11071

Browse files
archigupactions-usermoninom1
authored
Fix uninitialized variable in TM4C NetworkInterface.c (#1028)
* Fix uninitialized variable in TM4C NetworkInterface.c * Uncrustify: triggered by comment. * Update macro --------- Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Monika Singh <[email protected]>
1 parent c9e63fc commit ce11071

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

source/portable/NetworkInterface/TM4C/NetworkInterface.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
#include "NetworkInterface.h"
5858
#include "phyHandling.h"
5959

60-
#define BUFFER_SIZE ( ipTOTAL_ETHERNET_FRAME_SIZE + ipBUFFER_PADDING )
60+
#define BUFFER_SIZE_WO_PADDING ( ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER )
61+
#define BUFFER_SIZE ( BUFFER_SIZE_WO_PADDING + ipBUFFER_PADDING )
6162
#define BUFFER_SIZE_ROUNDED_UP ( ( BUFFER_SIZE + 7 ) & ~0x7UL )
6263
#define PHY_PHYS_ADDR 0
6364

@@ -446,7 +447,7 @@ static BaseType_t _ethernet_mac_get( uint8_t * mac_address_bytes )
446447
static void _dma_descriptors_init( void )
447448
{
448449
uint32_t i;
449-
size_t buffer_size_requested;
450+
const size_t buffer_size_requested = BUFFER_SIZE_WO_PADDING;
450451
NetworkBufferDescriptor_t * stack_descriptor;
451452

452453
/* Initialize the TX DMA descriptors */
@@ -592,6 +593,7 @@ static BaseType_t _process_received_packet( void )
592593
IPStackEvent_t event;
593594
BaseType_t result = pdTRUE;
594595
const TickType_t max_block_time = pdMS_TO_MIN_TICKS( 50 );
596+
const size_t buffer_size_requested = BUFFER_SIZE_WO_PADDING;
595597

596598
/* Go through the list of RX DMA descriptors */
597599
for( i = 0; i < niEMAC_RX_DMA_DESC_COUNT; i++ )
@@ -665,7 +667,8 @@ static BaseType_t _process_received_packet( void )
665667
} /* end if frame had error. In this case, give the buffer back to the DMA for the next RX */
666668

667669
/* Set up the DMA descriptor for the next receive transaction */
668-
dma_descriptor->ui32Count = DES1_RX_CTRL_CHAINED | ipTOTAL_ETHERNET_FRAME_SIZE;
670+
dma_descriptor->ui32Count = DES1_RX_CTRL_CHAINED | ( ( buffer_size_requested << DES1_RX_CTRL_BUFF1_SIZE_S ) & DES1_RX_CTRL_BUFF1_SIZE_M );
671+
669672
dma_descriptor->ui32CtrlStatus = DES0_RX_CTRL_OWN;
670673

671674
_rx_descriptor_list.write++;

0 commit comments

Comments
 (0)