mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-17 02:07:48 -04:00
TCP: Address MISRA rule11.3 violations (#225)
This commit is contained in:
parent
66371d0cf0
commit
3fc432f7be
6 changed files with 222 additions and 89 deletions
|
@ -250,16 +250,14 @@ struct xDNSMessage
|
|||
#include "pack_struct_end.h"
|
||||
typedef struct xDNSMessage DNSMessage_t;
|
||||
|
||||
static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( DNSMessage_t )
|
||||
{
|
||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||
return ( DNSMessage_t *)pvArgument;
|
||||
}
|
||||
static portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( DNSMessage_t )
|
||||
{
|
||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||
return ( const DNSMessage_t *) pvArgument;
|
||||
}
|
||||
static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( DNSMessage_t )
|
||||
{
|
||||
return ( DNSMessage_t *)pvArgument;
|
||||
}
|
||||
static portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( DNSMessage_t )
|
||||
{
|
||||
return ( const DNSMessage_t *) pvArgument;
|
||||
}
|
||||
|
||||
/* A DNS query consists of a header, as described in 'struct xDNSMessage'
|
||||
It is followed by 1 or more queries, each one consisting of a name and a tail,
|
||||
|
@ -274,11 +272,10 @@ struct xDNSTail
|
|||
#include "pack_struct_end.h"
|
||||
typedef struct xDNSTail DNSTail_t;
|
||||
|
||||
static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( DNSTail_t )
|
||||
{
|
||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||
return ( DNSTail_t * ) pvArgument;
|
||||
}
|
||||
static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( DNSTail_t )
|
||||
{
|
||||
return ( DNSTail_t * ) pvArgument;
|
||||
}
|
||||
|
||||
/* DNS answer record header. */
|
||||
#include "pack_struct_start.h"
|
||||
|
@ -292,11 +289,10 @@ struct xDNSAnswerRecord
|
|||
#include "pack_struct_end.h"
|
||||
typedef struct xDNSAnswerRecord DNSAnswerRecord_t;
|
||||
|
||||
static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( DNSAnswerRecord_t )
|
||||
{
|
||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||
return ( DNSAnswerRecord_t * ) pvArgument;
|
||||
}
|
||||
static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( DNSAnswerRecord_t )
|
||||
{
|
||||
return ( DNSAnswerRecord_t * ) pvArgument;
|
||||
}
|
||||
|
||||
#if( ipconfigUSE_LLMNR == 1 )
|
||||
|
||||
|
@ -314,6 +310,12 @@ typedef struct xDNSAnswerRecord DNSAnswerRecord_t;
|
|||
#include "pack_struct_end.h"
|
||||
typedef struct xLLMNRAnswer LLMNRAnswer_t;
|
||||
|
||||
static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( LLMNRAnswer_t )
|
||||
{
|
||||
return ( LLMNRAnswer_t *)pvArgument;
|
||||
}
|
||||
|
||||
|
||||
#endif /* ipconfigUSE_LLMNR == 1 */
|
||||
|
||||
#if( ipconfigUSE_NBNS == 1 )
|
||||
|
@ -349,6 +351,11 @@ typedef struct xDNSAnswerRecord DNSAnswerRecord_t;
|
|||
#include "pack_struct_end.h"
|
||||
typedef struct xNBNSAnswer NBNSAnswer_t;
|
||||
|
||||
static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( NBNSAnswer_t )
|
||||
{
|
||||
return ( NBNSAnswer_t *)pvArgument;
|
||||
}
|
||||
|
||||
#endif /* ipconfigUSE_NBNS == 1 */
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -376,6 +383,11 @@ typedef struct xDNSAnswerRecord DNSAnswerRecord_t;
|
|||
char pcName[ 1 ];
|
||||
} DNSCallback_t;
|
||||
|
||||
static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( DNSCallback_t )
|
||||
{
|
||||
return ( DNSCallback_t *)pvArgument;
|
||||
}
|
||||
|
||||
static List_t xCallbackList;
|
||||
|
||||
/* Define FreeRTOS_gethostbyname() as a normal blocking call. */
|
||||
|
@ -408,7 +420,7 @@ typedef struct xDNSAnswerRecord DNSAnswerRecord_t;
|
|||
pxIterator != xEnd;
|
||||
)
|
||||
{
|
||||
DNSCallback_t *pxCallback = ipPOINTER_CAST( DNSCallback_t *, listGET_LIST_ITEM_OWNER( pxIterator ) );
|
||||
DNSCallback_t *pxCallback = ipCAST_PTR_TO_TYPE_PTR( DNSCallback_t, listGET_LIST_ITEM_OWNER( pxIterator ) );
|
||||
/* Move to the next item because we might remove this item */
|
||||
pxIterator = ( const ListItem_t * ) listGET_NEXT( pxIterator );
|
||||
if( ( pvSearchID != NULL ) && ( pvSearchID == pxCallback->pvSearchID ) )
|
||||
|
@ -453,7 +465,7 @@ typedef struct xDNSAnswerRecord DNSAnswerRecord_t;
|
|||
TickType_t uxIdentifier )
|
||||
{
|
||||
size_t lLength = strlen( pcHostName );
|
||||
DNSCallback_t *pxCallback = ipPOINTER_CAST( DNSCallback_t *, pvPortMalloc( sizeof( *pxCallback ) + lLength ) );
|
||||
DNSCallback_t *pxCallback = ipCAST_PTR_TO_TYPE_PTR( DNSCallback_t, pvPortMalloc( sizeof( *pxCallback ) + lLength ) );
|
||||
|
||||
/* Translate from ms to number of clock ticks. */
|
||||
uxTimeout /= portTICK_PERIOD_MS;
|
||||
|
@ -471,7 +483,7 @@ typedef struct xDNSAnswerRecord DNSAnswerRecord_t;
|
|||
pxCallback->pvSearchID = pvSearchID;
|
||||
pxCallback->uxRemaningTime = uxTimeout;
|
||||
vTaskSetTimeOutState( &pxCallback->uxTimeoutState );
|
||||
listSET_LIST_ITEM_OWNER( &( pxCallback->xListItem ), ipPOINTER_CAST( void *, pxCallback ) );
|
||||
listSET_LIST_ITEM_OWNER( &( pxCallback->xListItem ), ( void *) pxCallback );
|
||||
listSET_LIST_ITEM_VALUE( &( pxCallback->xListItem ), uxIdentifier );
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
|
@ -500,7 +512,7 @@ typedef struct xDNSAnswerRecord DNSAnswerRecord_t;
|
|||
{
|
||||
if( listGET_LIST_ITEM_VALUE( pxIterator ) == uxIdentifier )
|
||||
{
|
||||
DNSCallback_t *pxCallback = ipPOINTER_CAST( DNSCallback_t *, listGET_LIST_ITEM_OWNER( pxIterator ) );
|
||||
DNSCallback_t *pxCallback = ipCAST_PTR_TO_TYPE_PTR( DNSCallback_t, listGET_LIST_ITEM_OWNER( pxIterator ) );
|
||||
|
||||
pxCallback->pCallbackFunction( pcName, pxCallback->pvSearchID, ulIPAddress );
|
||||
( void ) uxListRemove( &pxCallback->xListItem );
|
||||
|
@ -1415,7 +1427,7 @@ BaseType_t xReturn = pdTRUE;
|
|||
/* The test on 'pucNewBuffer' is only to satisfy lint. */
|
||||
if( ( pxNetworkBuffer != NULL ) && ( pucNewBuffer != NULL ) )
|
||||
{
|
||||
pxAnswer = ipPOINTER_CAST( LLMNRAnswer_t *, pucByte );
|
||||
pxAnswer = ipCAST_PTR_TO_TYPE_PTR( LLMNRAnswer_t, pucByte );
|
||||
|
||||
/* We leave 'usIdentifier' and 'usQuestions' untouched */
|
||||
#ifndef _lint
|
||||
|
@ -1604,8 +1616,8 @@ BaseType_t xReturn = pdTRUE;
|
|||
#else
|
||||
( void ) pxMessage;
|
||||
#endif
|
||||
|
||||
pxAnswer = ipPOINTER_CAST( NBNSAnswer_t *, &( pucUDPPayloadBuffer[ offsetof( NBNSRequest_t, usType ) ] ) );
|
||||
|
||||
pxAnswer = ipCAST_PTR_TO_TYPE_PTR( NBNSAnswer_t, &( pucUDPPayloadBuffer[ offsetof( NBNSRequest_t, usType ) ] ) );
|
||||
|
||||
#ifndef _lint
|
||||
vSetField16( pxAnswer, NBNSAnswer_t, usType, usType ); /* Type */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue