Skip to content

Commit d3668a6

Browse files
Update Agent to treat MQTTNeedMoreBytes correctly (#103)
* Update MQTT Agent to treat MQTTNeedMoreBytes correctly
1 parent a991b39 commit d3668a6

File tree

5 files changed

+13
-2
lines changed

5 files changed

+13
-2
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ jobs:
106106
config: .github/memory_statistics_config.json
107107
check_against: docs/doxygen/include/size_table.md
108108
proof_ci:
109-
runs-on: cbmc_ubuntu-latest_16-core
109+
runs-on: cbmc_ubuntu-latest_64-core
110110
steps:
111111
- name: Set up CBMC runner
112112
uses: FreeRTOS/CI-CD-Github-Actions/set_up_cbmc_runner@main

lexicon.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ mqtteventcallback
130130
mqttfixedbuffer
131131
mqttgetcurrenttimefunc
132132
mqttkeepalivetimeout
133+
mqttneedmorebytes
133134
mqttnomemory
134135
mqttnotconnected
135136
mqttpublishinfo

source/core_mqtt_agent.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,12 @@ static MQTTStatus_t processCommand( MQTTAgentContext_t * pMqttAgentContext,
613613
} while( pMqttAgentContext->packetReceivedInLoop );
614614
}
615615

616+
if( operationStatus == MQTTNeedMoreBytes )
617+
{
618+
/* Reset the operation status as MQTTNeedMoreBytes is not an error condition. */
619+
operationStatus = MQTTSuccess;
620+
}
621+
616622
/* Set the flag to break from the command loop. */
617623
*pEndLoop = ( commandOutParams.endLoop || ( operationStatus != MQTTSuccess ) );
618624

test/cbmc/proofs/MQTTAgent_CommandLoop/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ MAX_BOUND_FOR_COMMAND_LOOP=3
2727
# the loop 2 times will be enough for proving memory safety.
2828
MAX_BOUND_FOR_PROCESS_COMMAND_LOOP=2
2929

30+
# Force CBMC to only use the AgentMessageRecvStub function as the pointee of
31+
# the recv function.
32+
RESTRICT_FUNCTION_POINTER += MQTTAgent_CommandLoop.function_pointer_call.1/AgentMessageRecvStub
33+
3034
DEFINES += -DMQTT_AGENT_MAX_OUTSTANDING_ACKS=$(MQTT_AGENT_MAX_OUTSTANDING_ACKS)
3135

3236
INCLUDES +=

test/unit-test/mqtt_agent_utest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,7 @@ void test_MQTTAgent_CommandLoop_NoCommand_NoData( void )
17531753

17541754
mqttStatus = MQTTAgent_CommandLoop( &mqttAgentContext );
17551755

1756-
TEST_ASSERT_EQUAL( MQTTNeedMoreBytes, mqttStatus );
1756+
TEST_ASSERT_EQUAL( MQTTSuccess, mqttStatus );
17571757
}
17581758

17591759
/**

0 commit comments

Comments
 (0)