Skip to content

Commit

Permalink
Initialize variables in unit-test before use (#232)
Browse files Browse the repository at this point in the history
* Initialise variables in test before use

* Init variables in serializer tests

* Update uncrustify runner OS version
  • Loading branch information
AniruddhaKanhere authored Nov 22, 2022
1 parent d41f457 commit 13d80aa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
with:
path: ./
formatting:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Check formatting
Expand Down
10 changes: 5 additions & 5 deletions test/unit-test/core_mqtt_serializer_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ void test_MQTT_GetConnectPacketSize( void )
void test_MQTT_SerializeConnect( void )
{
MQTTConnectInfo_t connectInfo;
MQTTPublishInfo_t willInfo;
MQTTPublishInfo_t willInfo = { 0 };
size_t remainingLength = 0;
uint8_t buffer[ 70 + 2 * BUFFER_PADDING_LENGTH ];
size_t bufferSize = sizeof( buffer ) - 2 * BUFFER_PADDING_LENGTH;
Expand Down Expand Up @@ -2310,7 +2310,7 @@ void test_MQTT_SerializePublishHeader( void )

void test_MQTT_ProcessIncomingPacketTypeAndLength_PacketNULL( void )
{
uint8_t pBuffer[ 100 ];
uint8_t pBuffer[ 100 ] = { 0 };
size_t index = 0;
MQTTStatus_t status;

Expand All @@ -2337,7 +2337,7 @@ void test_MQTT_ProcessIncomingPacketTypeAndLength_BufferNULL( void )
void test_MQTT_ProcessIncomingPacketTypeAndLength_IndexNULL( void )
{
MQTTPacketInfo_t packetInfo;
uint8_t pBuffer[ 100 ];
uint8_t pBuffer[ 100 ] = { 0 };
MQTTStatus_t status;

status = MQTT_ProcessIncomingPacketTypeAndLength( pBuffer, NULL, &packetInfo );
Expand All @@ -2350,7 +2350,7 @@ void test_MQTT_ProcessIncomingPacketTypeAndLength_IndexNULL( void )
void test_MQTT_ProcessIncomingPacketTypeAndLength_NoData( void )
{
MQTTPacketInfo_t packetInfo;
uint8_t pBuffer[ 100 ];
uint8_t pBuffer[ 100 ] = { 0 };
size_t index = 0;
MQTTStatus_t status;

Expand Down Expand Up @@ -2698,7 +2698,7 @@ void test_MQTT_SerializeConnect_Invalid_Params()
{
MQTTStatus_t mqttStatus = MQTTSuccess;
size_t remainingLength = 0UL, packetSize = 0UL;
MQTTFixedBuffer_t networkBuffer;
MQTTFixedBuffer_t networkBuffer = { 0 };
MQTTConnectInfo_t connectInfo;

/* Test NULL pConnectInfo. */
Expand Down
10 changes: 5 additions & 5 deletions test/unit-test/core_mqtt_state_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void test_MQTT_ReserveState( void )
const uint16_t PACKET_ID3 = 3;
const size_t index = MQTT_STATE_ARRAY_MAX_COUNT / 2;
TransportInterface_t transport;
MQTTFixedBuffer_t networkBuffer;
MQTTFixedBuffer_t networkBuffer = { 0 };

transport.recv = transportRecvSuccess;
transport.send = transportSendSuccess;
Expand Down Expand Up @@ -371,7 +371,7 @@ void test_MQTT_ReserveState_compactRecords( void )
const uint16_t PACKET_ID2 = 2;

TransportInterface_t transport;
MQTTFixedBuffer_t networkBuffer;
MQTTFixedBuffer_t networkBuffer = { 0 };

transport.recv = transportRecvSuccess;
transport.send = transportSendSuccess;
Expand Down Expand Up @@ -547,7 +547,7 @@ void test_MQTT_UpdateStatePublish( void )
MQTTStatus_t status;

TransportInterface_t transport;
MQTTFixedBuffer_t networkBuffer;
MQTTFixedBuffer_t networkBuffer = { 0 };

transport.recv = transportRecvSuccess;
transport.send = transportSendSuccess;
Expand Down Expand Up @@ -757,7 +757,7 @@ void test_MQTT_UpdateStateAck( void )

const uint16_t PACKET_ID = 1;
TransportInterface_t transport;
MQTTFixedBuffer_t networkBuffer;
MQTTFixedBuffer_t networkBuffer = { 0 };

transport.recv = transportRecvSuccess;
transport.send = transportSendSuccess;
Expand Down Expand Up @@ -954,7 +954,7 @@ void test_MQTT_AckToResend( void )
MQTTPubAckInfo_t outgoingRecords[ MQTT_STATE_ARRAY_MAX_COUNT ] = { 0 };
MQTTStatus_t status;
TransportInterface_t transport;
MQTTFixedBuffer_t networkBuffer;
MQTTFixedBuffer_t networkBuffer = { 0 };

transport.recv = transportRecvSuccess;
transport.send = transportSendSuccess;
Expand Down

0 comments on commit 13d80aa

Please sign in to comment.