1
0
mirror of https://github.com/FreeRTOS/FreeRTOS-Plus-TCP synced 2025-10-20 13:23:44 +08:00

Misra: Fix Rule 8.13 violations (#507)

* MISRA: fix rule 8.13 violations

* Fix more 8.3 rules violation

* Misra rule 8.13 fixes

* Fix Unit Test
This commit is contained in:
alfred gedeon
2022-07-08 19:06:10 +02:00
committed by GitHub
parent 58e9e54070
commit 6b84c44e07
19 changed files with 60 additions and 60 deletions

View File

@@ -87,7 +87,7 @@ static eARPLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup,
/*-----------------------------------------------------------*/
static void vProcessARPPacketReply( ARPPacket_t * pxARPFrame,
static void vProcessARPPacketReply( const ARPPacket_t * pxARPFrame,
uint32_t ulSenderProtocolAddress );
/*-----------------------------------------------------------*/
@@ -312,10 +312,10 @@ eFrameProcessingResult_t eARPProcessPacket( ARPPacket_t * const pxARPFrame )
* @param[in] pxARPFrame: The ARP packet received.
* @param[in] ulSenderProtocolAddress: The IPv4 address involved.
*/
static void vProcessARPPacketReply( ARPPacket_t * pxARPFrame,
static void vProcessARPPacketReply( const ARPPacket_t * pxARPFrame,
uint32_t ulSenderProtocolAddress )
{
ARPHeader_t * pxARPHeader = &( pxARPFrame->xARPHeader );
const ARPHeader_t * pxARPHeader = &( pxARPFrame->xARPHeader );
uint32_t ulTargetProtocolAddress = pxARPHeader->ulTargetProtocolAddress;
/* If the packet is meant for this device or if the entry already exists. */
@@ -328,8 +328,8 @@ static void vProcessARPPacketReply( ARPPacket_t * pxARPFrame,
if( pxARPWaitingNetworkBuffer != NULL )
{
IPPacket_t * pxARPWaitingIPPacket = ( ( IPPacket_t * ) pxARPWaitingNetworkBuffer->pucEthernetBuffer );
IPHeader_t * pxARPWaitingIPHeader = &( pxARPWaitingIPPacket->xIPHeader );
const IPPacket_t * pxARPWaitingIPPacket = ( ( IPPacket_t * ) pxARPWaitingNetworkBuffer->pucEthernetBuffer );
const IPHeader_t * pxARPWaitingIPHeader = &( pxARPWaitingIPPacket->xIPHeader );
if( ulSenderProtocolAddress == pxARPWaitingIPHeader->ulSourceIPAddress )
{
@@ -398,11 +398,11 @@ BaseType_t xIsIPInARPCache( uint32_t ulAddressToLookup )
*
* @return pdTRUE if the packet needs ARP resolution, pdFALSE otherwise.
*/
BaseType_t xCheckRequiresARPResolution( NetworkBufferDescriptor_t * pxNetworkBuffer )
BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer )
{
BaseType_t xNeedsARPResolution = pdFALSE;
IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer );
IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader );
const IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer );
const IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader );
if( ( pxIPHeader->ulSourceIPAddress & xNetworkAddressing.ulNetMask ) == ( *ipLOCAL_IP_ADDRESS_POINTER & xNetworkAddressing.ulNetMask ) )
{
@@ -644,7 +644,7 @@ void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress,
*
* @return Either eARPCacheMiss or eARPCacheHit.
*/
eARPLookupResult_t eARPGetCacheEntryByMac( MACAddress_t * const pxMACAddress,
eARPLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress,
uint32_t * pulIPAddress )
{
BaseType_t x;

View File

@@ -134,7 +134,7 @@
* @return If the socket given as parameter is the DHCP socket - return
* pdTRUE, else pdFALSE.
*/
BaseType_t xIsDHCPSocket( Socket_t xSocket )
BaseType_t xIsDHCPSocket( const ConstSocket_t xSocket )
{
BaseType_t xReturn;
@@ -1168,7 +1168,8 @@
if( pucUDPPayloadBuffer != NULL )
{
void * pvCopySource, * pvCopyDest;
const void * pvCopySource;
void * pvCopyDest;
FreeRTOS_debug_printf( ( "vDHCPProcess: discover\n" ) );
iptraceSENDING_DHCP_DISCOVER();

View File

@@ -420,7 +420,7 @@
* @returns ip address or zero on error
*
*/
static uint32_t prvDNSReply( struct xDNSBuffer * pxReceiveBuffer,
static uint32_t prvDNSReply( const struct xDNSBuffer * pxReceiveBuffer,
TickType_t uxIdentifier )
{
uint32_t ulIPAddress = 0U;
@@ -466,7 +466,7 @@
static BaseType_t prvSendBuffer( const char * pcHostName,
TickType_t uxIdentifier,
Socket_t xDNSSocket,
struct freertos_sockaddr * pxAddress )
const struct freertos_sockaddr * pxAddress )
{
BaseType_t uxReturn = pdFAIL;
struct xDNSBuffer xDNSBuf = { 0 };

View File

@@ -85,12 +85,12 @@
static void prvUpdateCacheEntry( UBaseType_t uxIndex,
uint32_t ulTTL,
uint32_t * pulIP,
const uint32_t * pulIP,
uint32_t ulCurrentTimeSeconds );
static void prvInsertCacheEntry( const char * pcName,
uint32_t ulTTL,
uint32_t * pulIP,
const uint32_t * pulIP,
uint32_t ulCurrentTimeSeconds );
/**
@@ -304,7 +304,7 @@
*/
static void prvUpdateCacheEntry( UBaseType_t uxIndex,
uint32_t ulTTL,
uint32_t * pulIP,
const uint32_t * pulIP,
uint32_t ulCurrentTimeSeconds )
{
uint32_t ulIPAddressIndex = 0;
@@ -334,7 +334,7 @@
*/
static void prvInsertCacheEntry( const char * pcName,
uint32_t ulTTL,
uint32_t * pulIP,
const uint32_t * pulIP,
uint32_t ulCurrentTimeSeconds )
{
/* Add or update the item. */

View File

@@ -93,8 +93,8 @@
*
*/
BaseType_t DNS_SendRequest( Socket_t xDNSSocket,
struct freertos_sockaddr * xAddress,
struct xDNSBuffer * pxDNSBuf )
const struct freertos_sockaddr * xAddress,
const struct xDNSBuffer * pxDNSBuf )
{
BaseType_t xReturn = pdFALSE;
@@ -126,7 +126,7 @@
* @param xAddress address to read from
* @param pxReceiveBuffer buffer to fill with received data
*/
void DNS_ReadReply( Socket_t xDNSSocket,
void DNS_ReadReply( const ConstSocket_t xDNSSocket,
struct freertos_sockaddr * xAddress,
struct xDNSBuffer * pxReceiveBuffer )
{

View File

@@ -525,13 +525,13 @@
* @param xDoStore whether to update the cache
* @return ip address extracted from the frame or zero if not found
*/
uint32_t parseDNSAnswer( DNSMessage_t * pxDNSMessageHeader,
uint32_t parseDNSAnswer( const DNSMessage_t * pxDNSMessageHeader,
uint8_t * pucByte,
size_t uxSourceBytesRemaining,
size_t * uxBytesRead
#if ( ipconfigUSE_DNS_CACHE == 1 ) || ( ipconfigDNS_USE_CALLBACKS == 1 )
,
char * pcName,
const char * pcName,
BaseType_t xDoStore
#endif
)

View File

@@ -58,7 +58,7 @@
*/
#if ( ipconfigREPLY_TO_INCOMING_PINGS == 1 )
static eFrameProcessingResult_t prvProcessICMPEchoRequest( ICMPPacket_t * const pxICMPPacket,
NetworkBufferDescriptor_t * const pxNetworkBuffer );
const NetworkBufferDescriptor_t * const pxNetworkBuffer );
#endif /* ipconfigREPLY_TO_INCOMING_PINGS */
/*
@@ -79,7 +79,7 @@
* @return eReleaseBuffer when the message buffer should be released, or eReturnEthernetFrame
* when the packet should be returned.
*/
eFrameProcessingResult_t ProcessICMPPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer )
eFrameProcessingResult_t ProcessICMPPacket( const NetworkBufferDescriptor_t * const pxNetworkBuffer )
{
eFrameProcessingResult_t eReturn = eReleaseBuffer;
@@ -131,7 +131,7 @@
* @param[in,out] pxICMPPacket: The IP packet that contains the ICMP message.
*/
static eFrameProcessingResult_t prvProcessICMPEchoRequest( ICMPPacket_t * const pxICMPPacket,
NetworkBufferDescriptor_t * const pxNetworkBuffer )
const NetworkBufferDescriptor_t * const pxNetworkBuffer )
{
ICMPHeader_t * pxICMPHeader;
IPHeader_t * pxIPHeader;

View File

@@ -122,7 +122,7 @@ static void prvProcessIPEventsAndTimers( void );
* from the network hardware drivers and tasks that are using sockets. It also
* maintains a set of protocol timers.
*/
static void prvIPTask( void * pvParameters );
static void prvIPTask( const void * pvParameters );
/*
* Called when new data is available from the network interface.
@@ -225,7 +225,7 @@ static BaseType_t xIPTaskInitialised = pdFALSE;
*
* @param[in] pvParameters: Not used.
*/
static void prvIPTask( void * pvParameters )
static void prvIPTask( const void * pvParameters )
{
/* Just to prevent compiler warnings about unused parameters. */
( void ) pvParameters;
@@ -1516,7 +1516,7 @@ static eFrameProcessingResult_t prvAllowIPPacket( const IPPacket_t * const pxIPP
/* Identify the next protocol. */
if( pxIPPacket->xIPHeader.ucProtocol == ( uint8_t ) ipPROTOCOL_UDP )
{
ProtocolPacket_t * pxProtPack;
const ProtocolPacket_t * pxProtPack;
/* pxProtPack will point to the offset were the protocols begin. */
pxProtPack = ( ( ProtocolPacket_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ uxHeaderLength - ipSIZE_OF_IPv4_HEADER ] ) );

View File

@@ -289,10 +289,8 @@ NetworkBufferDescriptor_t * pxUDPPayloadBuffer_to_NetworkBuffer( const void * pv
BaseType_t xIsCallingFromIPTask( void )
{
BaseType_t xReturn;
TaskHandle_t xCurrentHandle, xCurrentIPTaskHandle;
xCurrentHandle = xTaskGetCurrentTaskHandle();
xCurrentIPTaskHandle = FreeRTOS_GetIPTaskHandle();
const struct tskTaskControlBlock * const xCurrentHandle = xTaskGetCurrentTaskHandle();
const struct tskTaskControlBlock * const xCurrentIPTaskHandle = FreeRTOS_GetIPTaskHandle();
if( xCurrentHandle == xCurrentIPTaskHandle )
{

View File

@@ -653,8 +653,8 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain,
*
* @return If the socket belongs to the socket set: the event bits, otherwise zero.
*/
EventBits_t FreeRTOS_FD_ISSET( Socket_t xSocket,
SocketSet_t xSocketSet )
EventBits_t FreeRTOS_FD_ISSET( const ConstSocket_t xSocket,
const ConstSocketSet_t xSocketSet )
{
EventBits_t xReturn;
const FreeRTOS_Socket_t * pxSocket = ( const FreeRTOS_Socket_t * ) xSocket;
@@ -829,12 +829,12 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain,
* returns a negative value, the cause can be looked-up in
* 'FreeRTOS_errno_TCP.h'.
*/
int32_t FreeRTOS_recvfrom( Socket_t xSocket,
int32_t FreeRTOS_recvfrom( const ConstSocket_t xSocket,
void * pvBuffer,
size_t uxBufferLength,
BaseType_t xFlags,
struct freertos_sockaddr * pxSourceAddress,
socklen_t * pxSourceAddressLength )
const socklen_t * pxSourceAddressLength )
{
BaseType_t lPacketCount;
NetworkBufferDescriptor_t * pxNetworkBuffer;
@@ -3031,7 +3031,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket )
* error code is returned.
*/
BaseType_t FreeRTOS_connect( Socket_t xClientSocket,
struct freertos_sockaddr * pxAddress,
const struct freertos_sockaddr * pxAddress,
socklen_t xAddressLength )
{
FreeRTOS_Socket_t * pxSocket = ( FreeRTOS_Socket_t * ) xClientSocket;
@@ -4642,7 +4642,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket )
* @return pdTRUE if the socket is valid, else pdFALSE.
*
*/
BaseType_t xSocketValid( Socket_t xSocket )
BaseType_t xSocketValid( const ConstSocket_t xSocket )
{
BaseType_t xReturnValue = pdFALSE;
@@ -4803,7 +4803,7 @@ BaseType_t xSocketValid( Socket_t xSocket )
*
* @param[in] pxSocketSet: The socket-set which is to be waited on for change.
*/
void vSocketSelect( SocketSelect_t * pxSocketSet )
void vSocketSelect( const SocketSelect_t * pxSocketSet )
{
BaseType_t xRound;
EventBits_t xSocketBits, xBitsToClear;

View File

@@ -518,7 +518,7 @@
int32_t lOffset, lStored;
BaseType_t xResult = 0;
uint32_t ulRxLength = ulReceiveLength;
uint8_t * pucRxBuffer = &( pucRecvData[ 0 ] );
const uint8_t * pucRxBuffer = &( pucRecvData[ 0 ] );
ulSequenceNumber = FreeRTOS_ntohl( pxTCPHeader->ulSequenceNumber );

View File

@@ -1064,7 +1064,7 @@
int32_t lReturn = -1;
uint32_t ulLast = ulSequenceNumber + ulLength;
uint32_t ulCurrentSequenceNumber = pxWindow->rx.ulCurrentSequenceNumber;
TCPSegment_t * pxFound;
const TCPSegment_t * pxFound;
/* See if there is more data in a contiguous block to make the
* SACK describe a longer range of data. */
@@ -1659,7 +1659,7 @@
* be sent when their timer has expired.
* @param[in] pxWindow: The descriptor of the TCP sliding windows.
*/
static TCPSegment_t * pxTCPWindowTx_GetWaitQueue( TCPWindow_t * pxWindow )
static TCPSegment_t * pxTCPWindowTx_GetWaitQueue( const TCPWindow_t * pxWindow )
{
TCPSegment_t * pxSegment = xTCPWindowPeekHead( &( pxWindow->xWaitQueue ) );
@@ -1883,7 +1883,7 @@
* @param[in] pxSegment: The segment that was just acknowledged.
*/
static void prvTCPWindowTxCheckAck_CalcSRTT( TCPWindow_t * pxWindow,
TCPSegment_t * pxSegment )
const TCPSegment_t * pxSegment )
{
int32_t mS = ( int32_t ) ulTimerGetAge( &( pxSegment->xTransmitTimer ) );

View File

@@ -88,7 +88,7 @@
BaseType_t xIsIPInARPCache( uint32_t ulAddressToLookup );
BaseType_t xCheckRequiresARPResolution( NetworkBufferDescriptor_t * pxNetworkBuffer );
BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer );
/*
* Look for ulIPAddress in the ARP cache. If the IP address exists, copy the
@@ -104,7 +104,7 @@
#if ( ipconfigUSE_ARP_REVERSED_LOOKUP != 0 )
/* Lookup an IP-address if only the MAC-address is known */
eARPLookupResult_t eARPGetCacheEntryByMac( MACAddress_t * const pxMACAddress,
eARPLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress,
uint32_t * pulIPAddress );
#endif

View File

@@ -218,7 +218,7 @@
eDHCPState_t eExpectedState );
/* Internal call: returns true if socket is the current DHCP socket */
BaseType_t xIsDHCPSocket( Socket_t xSocket );
BaseType_t xIsDHCPSocket( const ConstSocket_t xSocket );
/* The application can indicate a preferred IP address by calling this function

View File

@@ -39,10 +39,10 @@
Socket_t DNS_CreateSocket( TickType_t uxReadTimeOut_ticks );
BaseType_t DNS_SendRequest( Socket_t xDNSSocket,
struct freertos_sockaddr * xAddress,
struct xDNSBuffer * pxDNSBuf );
const struct freertos_sockaddr * xAddress,
const struct xDNSBuffer * pxDNSBuf );
void DNS_ReadReply( Socket_t xDNSSocket,
void DNS_ReadReply( const ConstSocket_t xDNSSocket,
struct freertos_sockaddr * xAddress,
struct xDNSBuffer * pxReceiveBuffer );

View File

@@ -79,13 +79,13 @@
uint32_t ulIPAddress );
#endif
uint32_t parseDNSAnswer( DNSMessage_t * pxDNSMessageHeader,
uint32_t parseDNSAnswer( const DNSMessage_t * pxDNSMessageHeader,
uint8_t * pucByte,
size_t uxSourceBytesRemaining,
size_t * uxBytesRead
#if ( ipconfigUSE_DNS_CACHE == 1 ) || ( ipconfigDNS_USE_CALLBACKS == 1 )
,
char * pcName,
const char * pcName,
BaseType_t xDoStore
#endif
);

View File

@@ -68,7 +68,7 @@
/*
* Process incoming ICMP packets.
*/
eFrameProcessingResult_t ProcessICMPPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer );
eFrameProcessingResult_t ProcessICMPPacket( const NetworkBufferDescriptor_t * const pxNetworkBuffer );
#endif /* ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) */
#ifdef __cplusplus

View File

@@ -857,7 +857,7 @@ BaseType_t xIsCallingFromIPTask( void );
EventGroupHandle_t xSelectGroup;
} SocketSelect_t;
extern void vSocketSelect( SocketSelect_t * pxSocketSet );
extern void vSocketSelect( const SocketSelect_t * pxSocketSet );
/** @brief Define the data that must be passed for a 'eSocketSelectEvent'. */
typedef struct xSocketSelectMessage

View File

@@ -184,7 +184,7 @@
typedef struct xSOCKET * Socket_t;
typedef struct xSOCKET const * ConstSocket_t;
extern BaseType_t xSocketValid( Socket_t xSocket );
extern BaseType_t xSocketValid( const ConstSocket_t xSocket );
/**
* FULL, UP-TO-DATE AND MAINTAINED REFERENCE DOCUMENTATION FOR ALL THESE
@@ -237,12 +237,12 @@
socklen_t xDestinationAddressLength );
/* Receive data from a UDP socket */
int32_t FreeRTOS_recvfrom( Socket_t xSocket,
int32_t FreeRTOS_recvfrom( const ConstSocket_t xSocket,
void * pvBuffer,
size_t uxBufferLength,
BaseType_t xFlags,
struct freertos_sockaddr * pxSourceAddress,
socklen_t * pxSourceAddressLength );
const socklen_t * pxSourceAddressLength );
/* Function to get the local address and IP port. */
@@ -286,7 +286,7 @@
/* Connect a TCP socket to a remote socket. */
BaseType_t FreeRTOS_connect( Socket_t xClientSocket,
struct freertos_sockaddr * pxAddress,
const struct freertos_sockaddr * pxAddress,
socklen_t xAddressLength );
/* Places a TCP socket into a state where it is listening for and can accept
@@ -500,6 +500,7 @@
* Berkeley API. */
struct xSOCKET_SET;
typedef struct xSOCKET_SET * SocketSet_t;
typedef struct xSOCKET_SET const * ConstSocketSet_t;
/* Create a socket set for use with the FreeRTOS_select() function */
SocketSet_t FreeRTOS_CreateSocketSet( void );
@@ -538,8 +539,8 @@
EventBits_t xBitsToClear );
/* Check if a socket in a socket set has an event bit set. */
EventBits_t FreeRTOS_FD_ISSET( Socket_t xSocket,
SocketSet_t xSocketSet );
EventBits_t FreeRTOS_FD_ISSET( const ConstSocket_t xSocket,
const ConstSocketSet_t xSocketSet );
#endif /* ( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) */