diff --git a/source/core_mqtt.c b/source/core_mqtt.c index 0fe719f5f..90f629142 100644 --- a/source/core_mqtt.c +++ b/source/core_mqtt.c @@ -605,7 +605,7 @@ static int32_t sendPacket( MQTTContext_t * pContext, if( bytesSent < 0 ) { - LogError( ( "Transport send failed. Error code=%d.", bytesSent ) ); + LogError( ( "Transport send failed. Error code=%ld.", ( long int ) bytesSent ) ); totalBytesSent = bytesSent; sendError = true; } @@ -620,11 +620,11 @@ static int32_t sendPacket( MQTTContext_t * pContext, bytesRemaining -= ( size_t ) bytesSent; totalBytesSent += bytesSent; pIndex += bytesSent; - LogDebug( ( "BytesSent=%d, BytesRemaining=%lu," - " TotalBytesSent=%d.", - bytesSent, + LogDebug( ( "BytesSent=%ld, BytesRemaining=%lu," + " TotalBytesSent=%ld.", + ( long int ) bytesSent, ( unsigned long ) bytesRemaining, - totalBytesSent ) ); + ( long int ) totalBytesSent ) ); } } @@ -632,8 +632,8 @@ static int32_t sendPacket( MQTTContext_t * pContext, if( totalBytesSent > 0 ) { pContext->lastPacketTime = sendTime; - LogDebug( ( "Successfully sent packet at time %u.", - sendTime ) ); + LogDebug( ( "Successfully sent packet at time %lu.", + ( unsigned long ) sendTime ) ); } return totalBytesSent; @@ -714,8 +714,8 @@ static int32_t recvExact( const MQTTContext_t * pContext, if( bytesRecvd < 0 ) { - LogError( ( "Network error while receiving packet: ReturnCode=%d.", - bytesRecvd ) ); + LogError( ( "Network error while receiving packet: ReturnCode=%ld.", + ( long int ) bytesRecvd ) ); totalBytesRecvd = bytesRecvd; receiveError = true; } @@ -731,11 +731,11 @@ static int32_t recvExact( const MQTTContext_t * pContext, bytesRemaining -= ( size_t ) bytesRecvd; totalBytesRecvd += ( int32_t ) bytesRecvd; pIndex += bytesRecvd; - LogDebug( ( "BytesReceived=%d, BytesRemaining=%lu, " - "TotalBytesReceived=%d.", - bytesRecvd, + LogDebug( ( "BytesReceived=%ld, BytesRemaining=%lu, " + "TotalBytesReceived=%ld.", + ( long int ) bytesRecvd, ( unsigned long ) bytesRemaining, - totalBytesRecvd ) ); + ( long int ) totalBytesRecvd ) ); } elapsedTimeMs = calculateElapsedTime( getTimeStampMs(), entryTimeMs ); @@ -784,8 +784,8 @@ static MQTTStatus_t discardPacket( const MQTTContext_t * pContext, if( bytesReceived != ( int32_t ) bytesToReceive ) { LogError( ( "Receive error while discarding packet." - "ReceivedBytes=%d, ExpectedBytes=%lu.", - bytesReceived, + "ReceivedBytes=%ld, ExpectedBytes=%lu.", + ( long int ) bytesReceived, ( unsigned long ) bytesToReceive ) ); receiveError = true; } @@ -810,8 +810,8 @@ static MQTTStatus_t discardPacket( const MQTTContext_t * pContext, if( totalBytesReceived == remainingLength ) { - LogError( ( "Dumped packet. DumpedBytes=%d.", - totalBytesReceived ) ); + LogError( ( "Dumped packet. DumpedBytes=%lu.", + ( unsigned long ) totalBytesReceived ) ); /* Packet dumped, so no data is available. */ status = MQTTNoDataAvailable; } @@ -851,14 +851,14 @@ static MQTTStatus_t receivePacket( const MQTTContext_t * pContext, if( bytesReceived == ( int32_t ) bytesToReceive ) { /* Receive successful, bytesReceived == bytesToReceive. */ - LogInfo( ( "Packet received. ReceivedBytes=%d.", - bytesReceived ) ); + LogInfo( ( "Packet received. ReceivedBytes=%ld.", + ( long int ) bytesReceived ) ); } else { - LogError( ( "Packet reception failed. ReceivedBytes=%d, " + LogError( ( "Packet reception failed. ReceivedBytes=%ld, " "ExpectedBytes=%lu.", - bytesReceived, + ( long int ) bytesReceived, ( unsigned long ) bytesToReceive ) ); status = MQTTRecvFailed; } @@ -941,16 +941,15 @@ static MQTTStatus_t sendPublishAcks( MQTTContext_t * pContext, if( status != MQTTSuccess ) { - LogError( ( "Failed to update state of publish %u.", packetId ) ); + LogError( ( "Failed to update state of publish %hu.", + ( unsigned short ) packetId ) ); } } else { - LogError( ( "Failed to send ACK packet: PacketType=%02x, " - "SentBytes=%d, " + LogError( ( "Failed to send ACK packet: PacketType=%02x, SentBytes=%ld, " "PacketSize=%lu.", - packetTypeByte, - bytesSent, + ( unsigned int ) packetTypeByte, ( long int ) bytesSent, MQTT_PUBLISH_ACK_PACKET_SIZE ) ); status = MQTTSendFailed; } @@ -1064,8 +1063,8 @@ static MQTTStatus_t handleIncomingPublish( MQTTContext_t * pContext, publishRecordState = MQTT_CalculateStatePublish( MQTT_RECEIVE, publishInfo.qos ); - LogDebug( ( "Incoming publish packet with packet id %u already exists.", - packetIdentifier ) ); + LogDebug( ( "Incoming publish packet with packet id %hu already exists.", + ( unsigned short ) packetIdentifier ) ); if( publishInfo.dup == false ) { @@ -1074,9 +1073,9 @@ static MQTTStatus_t handleIncomingPublish( MQTTContext_t * pContext, } else { - LogError( ( "Error in updating publish state for incoming publish with packet id %u." + LogError( ( "Error in updating publish state for incoming publish with packet id %hu." " Error is %s", - packetIdentifier, + ( unsigned short ) packetIdentifier, MQTT_Status_strerror( status ) ) ); } } @@ -1146,9 +1145,9 @@ static MQTTStatus_t handlePublishAcks( MQTTContext_t * pContext, } else { - LogError( ( "Updating the state engine for packet id %u" + LogError( ( "Updating the state engine for packet id %hu" " failed with error %s.", - packetIdentifier, + ( unsigned short ) packetIdentifier, MQTT_Status_strerror( status ) ) ); } } @@ -1197,7 +1196,8 @@ static MQTTStatus_t handleIncomingAck( MQTTContext_t * pContext, appCallback = pContext->appCallback; - LogDebug( ( "Received packet of type %02x.", pIncomingPacket->type ) ); + LogDebug( ( "Received packet of type %02x.", + ( unsigned int ) pIncomingPacket->type ) ); switch( pIncomingPacket->type ) { @@ -1232,7 +1232,7 @@ static MQTTStatus_t handleIncomingAck( MQTTContext_t * pContext, default: /* Bad response from the server. */ LogError( ( "Unexpected packet type from server: PacketType=%02x.", - pIncomingPacket->type ) ); + ( unsigned int ) pIncomingPacket->type ) ); status = MQTTBadResponse; break; } @@ -1385,8 +1385,8 @@ static MQTTStatus_t sendPublish( MQTTContext_t * pContext, } else { - LogDebug( ( "Sent %d bytes of PUBLISH header.", - bytesSent ) ); + LogDebug( ( "Sent %ld bytes of PUBLISH header.", + ( long int ) bytesSent ) ); /* Send Payload if there is one to send. It is valid for a PUBLISH * Packet to contain a zero length payload.*/ @@ -1403,8 +1403,8 @@ static MQTTStatus_t sendPublish( MQTTContext_t * pContext, } else { - LogDebug( ( "Sent %d bytes of PUBLISH payload.", - bytesSent ) ); + LogDebug( ( "Sent %ld bytes of PUBLISH payload.", + ( long int ) bytesSent ) ); } } else @@ -1500,7 +1500,7 @@ static MQTTStatus_t receiveConnack( const MQTTContext_t * pContext, { LogError( ( "Incorrect packet type %X received while expecting" " CONNACK(%X).", - pIncomingPacket->type, + ( unsigned int ) pIncomingPacket->type, MQTT_PACKET_TYPE_CONNACK ) ); status = MQTTBadResponse; } @@ -1636,7 +1636,7 @@ static MQTTStatus_t validatePublishParams( const MQTTContext_t * pContext, else if( ( pPublishInfo->qos != MQTTQoS0 ) && ( packetId == 0U ) ) { LogError( ( "Packet Id is 0 for PUBLISH with QoS=%u.", - pPublishInfo->qos ) ); + ( unsigned int ) pPublishInfo->qos ) ); status = MQTTBadParameter; } else if( ( pPublishInfo->payloadLength > 0U ) && ( pPublishInfo->pPayload == NULL ) ) @@ -1772,8 +1772,8 @@ MQTTStatus_t MQTT_Connect( MQTTContext_t * pContext, } else { - LogDebug( ( "Sent %d bytes of CONNECT packet.", - bytesSent ) ); + LogDebug( ( "Sent %ld bytes of CONNECT packet.", + ( long int ) bytesSent ) ); } } @@ -1863,8 +1863,8 @@ MQTTStatus_t MQTT_Subscribe( MQTTContext_t * pContext, } else { - LogDebug( ( "Sent %d bytes of SUBSCRIBE packet.", - bytesSent ) ); + LogDebug( ( "Sent %ld bytes of SUBSCRIBE packet.", + ( long int ) bytesSent ) ); } } @@ -1998,8 +1998,8 @@ MQTTStatus_t MQTT_Ping( MQTTContext_t * pContext ) { pContext->pingReqSendTimeMs = pContext->lastPacketTime; pContext->waitingForPingResp = true; - LogDebug( ( "Sent %d bytes of PINGREQ packet.", - bytesSent ) ); + LogDebug( ( "Sent %ld bytes of PINGREQ packet.", + ( long int ) bytesSent ) ); } } @@ -2058,8 +2058,8 @@ MQTTStatus_t MQTT_Unsubscribe( MQTTContext_t * pContext, } else { - LogDebug( ( "Sent %d bytes of UNSUBSCRIBE packet.", - bytesSent ) ); + LogDebug( ( "Sent %ld bytes of UNSUBSCRIBE packet.", + ( long int ) bytesSent ) ); } } @@ -2108,8 +2108,8 @@ MQTTStatus_t MQTT_Disconnect( MQTTContext_t * pContext ) } else { - LogDebug( ( "Sent %d bytes of DISCONNECT packet.", - bytesSent ) ); + LogDebug( ( "Sent %ld bytes of DISCONNECT packet.", + ( long int ) bytesSent ) ); } } @@ -2274,18 +2274,18 @@ MQTTStatus_t MQTT_MatchTopic( const char * pTopicName, if( ( pTopicName == NULL ) || ( topicNameLength == 0u ) ) { LogError( ( "Invalid paramater: Topic name should be non-NULL and its " - "length should be > 0: TopicName=%p, TopicNameLength=%u", + "length should be > 0: TopicName=%p, TopicNameLength=%hu", ( void * ) pTopicName, - topicNameLength ) ); + ( unsigned short ) topicNameLength ) ); status = MQTTBadParameter; } else if( ( pTopicFilter == NULL ) || ( topicFilterLength == 0u ) ) { LogError( ( "Invalid paramater: Topic filter should be non-NULL and " - "its length should be > 0: TopicName=%p, TopicFilterLength=%u", + "its length should be > 0: TopicName=%p, TopicFilterLength=%hu", ( void * ) pTopicFilter, - topicFilterLength ) ); + ( unsigned short ) topicFilterLength ) ); status = MQTTBadParameter; } else if( pIsMatch == NULL ) @@ -2355,7 +2355,8 @@ MQTTStatus_t MQTT_GetSubAckStatusCodes( const MQTTPacketInfo_t * pSubackPacket, { LogError( ( "Invalid parameter: Input packet is not a SUBACK packet: " "ExpectedType=%02x, InputType=%02x", - MQTT_PACKET_TYPE_SUBACK, pSubackPacket->type ) ); + ( int ) MQTT_PACKET_TYPE_SUBACK, + ( int ) pSubackPacket->type ) ); status = MQTTBadParameter; } else if( pSubackPacket->pRemainingData == NULL ) diff --git a/source/core_mqtt_serializer.c b/source/core_mqtt_serializer.c index 5c80bfd7b..3582102f9 100644 --- a/source/core_mqtt_serializer.c +++ b/source/core_mqtt_serializer.c @@ -789,7 +789,7 @@ static bool incomingPacketValid( uint8_t packetType ) /* Any other packet type is invalid. */ default: LogWarn( ( "Incoming packet invalid: Packet type=%u.", - packetType ) ); + ( unsigned int ) packetType ) ); break; } @@ -870,17 +870,17 @@ static MQTTStatus_t processPublishFlags( uint8_t publishFlags, if( status == MQTTSuccess ) { - LogDebug( ( "QoS is %d.", pPublishInfo->qos ) ); + LogDebug( ( "QoS is %d.", ( int ) pPublishInfo->qos ) ); /* Parse the Retain bit. */ pPublishInfo->retain = ( UINT8_CHECK_BIT( publishFlags, MQTT_PUBLISH_FLAG_RETAIN ) ) ? true : false; - LogDebug( ( "Retain bit is %d.", pPublishInfo->retain ) ); + LogDebug( ( "Retain bit is %d.", ( int ) pPublishInfo->retain ) ); /* Parse the DUP bit. */ pPublishInfo->dup = ( UINT8_CHECK_BIT( publishFlags, MQTT_PUBLISH_FLAG_DUP ) ) ? true : false; - LogDebug( ( "DUP bit is %d.", pPublishInfo->dup ) ); + LogDebug( ( "DUP bit is %d.", ( int ) pPublishInfo->dup ) ); } return status; @@ -934,8 +934,8 @@ static MQTTStatus_t deserializeConnack( const MQTTPacketInfo_t * pConnack, * "Remaining length" of 2. */ if( pConnack->remainingLength != MQTT_PACKET_CONNACK_REMAINING_LENGTH ) { - LogError( ( "CONNACK does not have remaining length of %d.", - MQTT_PACKET_CONNACK_REMAINING_LENGTH ) ); + LogError( ( "CONNACK does not have remaining length of %u.", + ( unsigned int ) MQTT_PACKET_CONNACK_REMAINING_LENGTH ) ); status = MQTTBadResponse; } @@ -977,7 +977,8 @@ static MQTTStatus_t deserializeConnack( const MQTTPacketInfo_t * pConnack, /* In MQTT 3.1.1, only values 0 through 5 are valid CONNACK response codes. */ if( pRemainingData[ 1 ] > 5U ) { - LogError( ( "CONNACK response %u is invalid.", pRemainingData[ 1 ] ) ); + LogError( ( "CONNACK response %u is invalid.", + ( unsigned int ) pRemainingData[ 1 ] ) ); status = MQTTBadResponse; } @@ -1089,7 +1090,8 @@ static MQTTStatus_t readSubackStatus( size_t statusCount, case 0x02: LogDebug( ( "Topic filter %lu accepted, max QoS %u.", - ( unsigned long ) i, subscriptionStatus ) ); + ( unsigned long ) i, + ( unsigned int ) subscriptionStatus ) ); break; case 0x80: @@ -1102,7 +1104,8 @@ static MQTTStatus_t readSubackStatus( size_t statusCount, break; default: - LogDebug( ( "Bad SUBSCRIBE status %u.", subscriptionStatus ) ); + LogDebug( ( "Bad SUBSCRIBE status %u.", + ( unsigned int ) subscriptionStatus ) ); status = MQTTBadResponse; @@ -1146,7 +1149,8 @@ static MQTTStatus_t deserializeSuback( const MQTTPacketInfo_t * pSuback, /* Extract the packet identifier (first 2 bytes of variable header) from SUBACK. */ *pPacketIdentifier = UINT16_DECODE( pVariableHeader ); - LogDebug( ( "Packet identifier %hu.", *pPacketIdentifier ) ); + LogDebug( ( "Packet identifier %hu.", + ( unsigned short ) *pPacketIdentifier ) ); status = readSubackStatus( remainingLength - sizeof( uint16_t ), pVariableHeader + sizeof( uint16_t ) ); @@ -1260,7 +1264,7 @@ static MQTTStatus_t deserializePublish( const MQTTPacketInfo_t * pIncomingPacket /* Parse the topic. */ pPublishInfo->pTopicName = ( const char * ) ( pVariableHeader + sizeof( uint16_t ) ); LogDebug( ( "Topic name length %hu: %.*s", - pPublishInfo->topicNameLength, + ( unsigned short ) pPublishInfo->topicNameLength, pPublishInfo->topicNameLength, pPublishInfo->pTopicName ) ); @@ -1272,7 +1276,8 @@ static MQTTStatus_t deserializePublish( const MQTTPacketInfo_t * pIncomingPacket { *pPacketId = UINT16_DECODE( pPacketIdentifierHigh ); - LogDebug( ( "Packet identifier %hu.", *pPacketId ) ); + LogDebug( ( "Packet identifier %hu.", + ( unsigned short ) *pPacketId ) ); /* Advance pointer two bytes to start of payload as in the QoS 0 case. */ pPacketIdentifierHigh += sizeof( uint16_t ); @@ -1300,7 +1305,8 @@ static MQTTStatus_t deserializePublish( const MQTTPacketInfo_t * pIncomingPacket /* Set payload if it exists. */ pPublishInfo->pPayload = ( pPublishInfo->payloadLength != 0U ) ? pPacketIdentifierHigh : NULL; - LogDebug( ( "Payload length %lu.", ( unsigned long ) pPublishInfo->payloadLength ) ); + LogDebug( ( "Payload length %lu.", + ( unsigned long ) pPublishInfo->payloadLength ) ); } return status; @@ -1319,8 +1325,8 @@ static MQTTStatus_t deserializeSimpleAck( const MQTTPacketInfo_t * pAck, /* Check that the "Remaining length" of the received ACK is 2. */ if( pAck->remainingLength != MQTT_PACKET_SIMPLE_ACK_REMAINING_LENGTH ) { - LogError( ( "ACK does not have remaining length of %d.", - MQTT_PACKET_SIMPLE_ACK_REMAINING_LENGTH ) ); + LogError( ( "ACK does not have remaining length of %u.", + ( unsigned int ) MQTT_PACKET_SIMPLE_ACK_REMAINING_LENGTH ) ); status = MQTTBadResponse; } @@ -1329,7 +1335,8 @@ static MQTTStatus_t deserializeSimpleAck( const MQTTPacketInfo_t * pAck, /* Extract the packet identifier (third and fourth bytes) from ACK. */ *pPacketIdentifier = UINT16_DECODE( pAck->pRemainingData ); - LogDebug( ( "Packet identifier %hu.", *pPacketIdentifier ) ); + LogDebug( ( "Packet identifier %hu.", + ( unsigned short ) *pPacketIdentifier ) ); /* Packet identifier cannot be 0. */ if( *pPacketIdentifier == 0U ) @@ -1352,7 +1359,7 @@ static MQTTStatus_t deserializePingresp( const MQTTPacketInfo_t * pPingresp ) /* Check the "Remaining length" (second byte) of the received PINGRESP is 0. */ if( pPingresp->remainingLength != MQTT_PACKET_PINGRESP_REMAINING_LENGTH ) { - LogError( ( "PINGRESP does not have remaining length of %d.", + LogError( ( "PINGRESP does not have remaining length of %u.", MQTT_PACKET_PINGRESP_REMAINING_LENGTH ) ); status = MQTTBadResponse; @@ -1853,9 +1860,9 @@ MQTTStatus_t MQTT_GetPublishPacketSize( const MQTTPublishInfo_t * pPublishInfo, else if( ( pPublishInfo->pTopicName == NULL ) || ( pPublishInfo->topicNameLength == 0U ) ) { LogError( ( "Invalid topic name for PUBLISH: pTopicName=%p, " - "topicNameLength=%u.", - pPublishInfo->pTopicName, - pPublishInfo->topicNameLength ) ); + "topicNameLength=%hu.", + ( void * ) pPublishInfo->pTopicName, + ( unsigned short ) pPublishInfo->topicNameLength ) ); status = MQTTBadParameter; } else @@ -1912,20 +1919,20 @@ MQTTStatus_t MQTT_SerializePublish( const MQTTPublishInfo_t * pPublishInfo, else if( ( pPublishInfo->pTopicName == NULL ) || ( pPublishInfo->topicNameLength == 0U ) ) { LogError( ( "Invalid topic name for PUBLISH: pTopicName=%p, " - "topicNameLength=%u.", - pPublishInfo->pTopicName, - pPublishInfo->topicNameLength ) ); + "topicNameLength=%hu.", + ( void * ) pPublishInfo->pTopicName, + ( unsigned short ) pPublishInfo->topicNameLength ) ); status = MQTTBadParameter; } else if( ( pPublishInfo->qos != MQTTQoS0 ) && ( packetId == 0U ) ) { LogError( ( "Packet ID is 0 for PUBLISH with QoS=%u.", - pPublishInfo->qos ) ); + ( unsigned int ) pPublishInfo->qos ) ); status = MQTTBadParameter; } else if( ( pPublishInfo->dup == true ) && ( pPublishInfo->qos == MQTTQoS0 ) ) { - LogError( ( "Duplicate flag is set for PUBLISH with Qos 0," ) ); + LogError( ( "Duplicate flag is set for PUBLISH with Qos 0." ) ); status = MQTTBadParameter; } else @@ -1989,20 +1996,20 @@ MQTTStatus_t MQTT_SerializePublishHeader( const MQTTPublishInfo_t * pPublishInfo else if( ( pPublishInfo->pTopicName == NULL ) || ( pPublishInfo->topicNameLength == 0U ) ) { LogError( ( "Invalid topic name for publish: pTopicName=%p, " - "topicNameLength=%u.", - pPublishInfo->pTopicName, - pPublishInfo->topicNameLength ) ); + "topicNameLength=%hu.", + ( void * ) pPublishInfo->pTopicName, + ( unsigned short ) pPublishInfo->topicNameLength ) ); status = MQTTBadParameter; } else if( ( pPublishInfo->qos != MQTTQoS0 ) && ( packetId == 0U ) ) { - LogError( ( "Packet Id is 0 for publish with QoS=%u.", - pPublishInfo->qos ) ); + LogError( ( "Packet Id is 0 for publish with QoS=%hu.", + ( unsigned short ) pPublishInfo->qos ) ); status = MQTTBadParameter; } else if( ( pPublishInfo->dup == true ) && ( pPublishInfo->qos == MQTTQoS0 ) ) { - LogError( ( "Duplicate flag is set for PUBLISH with Qos 0," ) ); + LogError( ( "Duplicate flag is set for PUBLISH with Qos 0." ) ); status = MQTTBadParameter; } else @@ -2088,7 +2095,7 @@ MQTTStatus_t MQTT_SerializeAck( const MQTTFixedBuffer_t * pFixedBuffer, default: LogError( ( "Packet type is not a publish ACK: Packet type=%02x", - packetType ) ); + ( unsigned int ) packetType ) ); status = MQTTBadParameter; break; } @@ -2206,7 +2213,7 @@ MQTTStatus_t MQTT_SerializePingreq( const MQTTFixedBuffer_t * pFixedBuffer ) if( pFixedBuffer->size < MQTT_PACKET_PINGREQ_SIZE ) { LogError( ( "Buffer size of %lu is not sufficient to hold " - "serialized PINGREQ packet of size of %u.", + "serialized PINGREQ packet of size of %lu.", ( unsigned long ) pFixedBuffer->size, MQTT_PACKET_PINGREQ_SIZE ) ); status = MQTTNoMemory; @@ -2243,7 +2250,7 @@ MQTTStatus_t MQTT_DeserializePublish( const MQTTPacketInfo_t * pIncomingPacket, else if( ( pIncomingPacket->type & 0xF0U ) != MQTT_PACKET_TYPE_PUBLISH ) { LogError( ( "Packet is not publish. Packet type: %02x.", - pIncomingPacket->type ) ); + ( unsigned int ) pIncomingPacket->type ) ); status = MQTTBadParameter; } else if( pIncomingPacket->pRemainingData == NULL ) @@ -2281,7 +2288,7 @@ MQTTStatus_t MQTT_DeserializeAck( const MQTTPacketInfo_t * pIncomingPacket, ( pIncomingPacket->type != MQTT_PACKET_TYPE_PINGRESP ) ) ) { LogError( ( "pPacketId cannot be NULL for packet type %02x.", - pIncomingPacket->type ) ); + ( unsigned int ) pIncomingPacket->type ) ); status = MQTTBadParameter; } /* Pointer for session present cannot be NULL for CONNACK. */ @@ -2327,7 +2334,8 @@ MQTTStatus_t MQTT_DeserializeAck( const MQTTPacketInfo_t * pIncomingPacket, /* Any other packet type is invalid. */ default: - LogError( ( "IotMqtt_DeserializeResponse() called with unknown packet type:(%02x).", pIncomingPacket->type ) ); + LogError( ( "IotMqtt_DeserializeResponse() called with unknown packet type:(%02x).", + ( unsigned int ) pIncomingPacket->type ) ); status = MQTTBadResponse; break; } @@ -2374,7 +2382,7 @@ MQTTStatus_t MQTT_GetIncomingPacketTypeAndLength( TransportRecv_t readFunc, else { LogError( ( "Incoming packet invalid: Packet type=%u.", - pIncomingPacket->type ) ); + ( unsigned int ) pIncomingPacket->type ) ); status = MQTTBadResponse; } } @@ -2389,8 +2397,8 @@ MQTTStatus_t MQTT_GetIncomingPacketTypeAndLength( TransportRecv_t readFunc, else if( status != MQTTBadParameter ) { LogError( ( "A single byte was not read from the transport: " - "transportStatus=%d.", - bytesReceived ) ); + "transportStatus=%ld.", + ( long int ) bytesReceived ) ); status = MQTTRecvFailed; } else diff --git a/source/core_mqtt_state.c b/source/core_mqtt_state.c index a20a31a1d..b9859acd6 100644 --- a/source/core_mqtt_state.c +++ b/source/core_mqtt_state.c @@ -527,9 +527,9 @@ static MQTTStatus_t addRecord( MQTTPubAckInfo_t * records, if( records[ index ].packetId == packetId ) { /* Collision. */ - LogError( ( "Collision when adding PacketID=%u at index=%u.", - packetId, - index ) ); + LogError( ( "Collision when adding PacketID=%u at index=%d.", + ( unsigned int ) packetId, + ( int ) index ) ); status = MQTTStateCollision; availableIndex = recordCount; @@ -941,7 +941,7 @@ MQTTStatus_t MQTT_UpdateStateAck( MQTTContext_t * pMqttContext, } else if( packetType > MQTTPubcomp ) { - LogError( ( "Invalid packet type %u.", packetType ) ); + LogError( ( "Invalid packet type %u.", ( unsigned int ) packetType ) ); status = MQTTBadParameter; } else @@ -977,7 +977,8 @@ MQTTStatus_t MQTT_UpdateStateAck( MQTTContext_t * pMqttContext, } else { - LogError( ( "No matching record found for publish: PacketId=%u.", packetId ) ); + LogError( ( "No matching record found for publish: PacketId=%u.", + ( unsigned int ) packetId ) ); } return status;