Skip to content

Commit 59fa9d2

Browse files
committed
reason code change
1 parent d52bddf commit 59fa9d2

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

source/core_mqtt_serializer.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ static MQTTStatus_t decodeAndDiscard( size_t * pPropertyLength,
388388
*
389389
* @return #MQTTSuccess if variable length and paramters are valid else #MQTTBadParameter.
390390
*/
391-
static MQTTStatus_t decodeVariableLength( uint8_t * pBuffer,
391+
static MQTTStatus_t decodeVariableLength( const uint8_t * pBuffer,
392392
size_t * pLength );
393393

394394
/**
@@ -1928,7 +1928,7 @@ MQTTStatus_t MQTT_GetDisconnectPacketSize( size_t * pRemainingLength,
19281928
LogError( ( "Max packet size cannot be zero." ) );
19291929
status = MQTTBadParameter;
19301930
}
1931-
else if(validateDisconnectResponse( reasonCode, false ) != MQTTSuccess )
1931+
else if(validateDisconnectResponse( (uint8_t)reasonCode, false ) != MQTTSuccess )
19321932
{
19331933
LogError( ( "Invalid reason code." ) );
19341934
status = MQTTBadParameter;
@@ -2300,7 +2300,7 @@ static MQTTStatus_t validateConnackParams( const MQTTPacketInfo_t * pIncomingPac
23002300

23012301
/*-----------------------------------------------------------*/
23022302

2303-
static MQTTStatus_t decodeVariableLength(uint8_t* pBuffer,
2303+
static MQTTStatus_t decodeVariableLength(const uint8_t* pBuffer,
23042304
size_t* pLength)
23052305
{
23062306
size_t remainingLength = 0;
@@ -2676,8 +2676,8 @@ static MQTTStatus_t logAckResponse( uint8_t reasonCode,
26762676
uint16_t packetIdentifier )
26772677
{
26782678
MQTTStatus_t status = MQTTServerRefused;
2679-
2680-
switch( reasonCode )
2679+
/* coverity[misra_c_2012_rule_10_5_violation] */
2680+
switch( (MQTTSuccessFailReasonCode_t) reasonCode )
26812681
{
26822682
case MQTT_REASON_PUBACK_SUCCESS:
26832683
( void ) packetIdentifier;
@@ -2739,8 +2739,8 @@ static MQTTStatus_t logSimpleAckResponse( uint8_t reasonCode,
27392739
uint16_t packetIdentifier )
27402740
{
27412741
MQTTStatus_t status = MQTTServerRefused;
2742-
2743-
switch( reasonCode )
2742+
/* coverity[misra_c_2012_rule_10_5_violation] */
2743+
switch( (MQTTSuccessFailReasonCode_t) reasonCode )
27442744
{
27452745
case MQTT_REASON_PUBREL_SUCCESS:
27462746
( void ) packetIdentifier;
@@ -2841,7 +2841,8 @@ static MQTTStatus_t validateDisconnectResponse( uint8_t reasonCode,
28412841
MQTTStatus_t status;
28422842

28432843
/*Validate the reason code.*/
2844-
switch( reasonCode )
2844+
/* coverity[misra_c_2012_rule_10_5_violation] */
2845+
switch( (MQTTSuccessFailReasonCode_t)reasonCode )
28452846
{
28462847
case MQTT_REASON_DISCONNECT_DISCONNECT_WITH_WILL_MESSAGE:
28472848

source/include/core_mqtt_serializer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ typedef struct MQTTConnectProperties
659659
*/
660660
typedef struct MQTTReasonCodeInfo
661661
{
662-
uint8_t * reasonCode;
662+
const uint8_t * reasonCode;
663663
size_t reasonCodeLength ;
664664

665665
} MQTTReasonCodeInfo_t;

0 commit comments

Comments
 (0)