Skip to content

Commit c28847d

Browse files
Fix CBMC proof of ProcessDHCPReplies (FreeRTOS#177)
* Update Proof * Uncrustify and fix one broken proof due to removal of _static * Uncrustify * Update the comments
1 parent 43914be commit c28847d

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

FreeRTOS_DHCP.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@
217217
/*
218218
* Interpret message received on the DHCP socket.
219219
*/
220-
_static BaseType_t prvProcessDHCPReplies( BaseType_t xExpectedMessageType,
221-
NetworkEndPoint_t * pxEndPoint );
220+
static BaseType_t prvProcessDHCPReplies( BaseType_t xExpectedMessageType,
221+
NetworkEndPoint_t * pxEndPoint );
222222

223223
/*
224224
* Generate a DHCP request packet, and send it on the DHCP socket.
@@ -966,8 +966,8 @@
966966
*
967967
* @return pdPASS: if DHCP options are received correctly; pdFAIL: Otherwise.
968968
*/
969-
_static BaseType_t prvProcessDHCPReplies( BaseType_t xExpectedMessageType,
970-
NetworkEndPoint_t * pxEndPoint )
969+
static BaseType_t prvProcessDHCPReplies( BaseType_t xExpectedMessageType,
970+
NetworkEndPoint_t * pxEndPoint )
971971
{
972972
uint8_t * pucUDPPayload;
973973
int32_t lBytes;

test/cbmc/proofs/DHCP/DHCPProcessEndPoint/DHCPProcessEndPoint_harness.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain,
9797
* Function Abstraction:
9898
* prvProcessDHCPReplies has been proved memory safe in ProcessDHCPReplies.
9999
****************************************************************/
100-
BaseType_t prvProcessDHCPReplies( BaseType_t xExpectedMessageType,
101-
NetworkEndPoint_t * pxEndPoint )
100+
BaseType_t __CPROVER_file_local_FreeRTOS_DHCP_c_prvProcessDHCPReplies( BaseType_t xExpectedMessageType,
101+
NetworkEndPoint_t * pxEndPoint )
102102
{
103103
return nondet_BaseType();
104104
}

test/cbmc/proofs/ProcessDHCPReplies/Makefile.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"CBMCFLAGS": [
2727
# "--nondet-static",
2828
"--unwind 1",
29-
"--unwindset memcmp.0:7,prvProcessDHCPReplies.0:{BUFFER_PAYLOAD}"
29+
"--unwindset memcmp.0:7,__CPROVER_file_local_FreeRTOS_DHCP_c_prvProcessDHCPReplies.0:{BUFFER_PAYLOAD}"
3030
],
3131

3232
"OBJS":
@@ -44,5 +44,11 @@
4444
[
4545
"CBMC_DHCPMESSAGE_HEADER_SIZE={BUFFER_HEADER}",
4646
"CBMC_FREERTOS_RECVFROM_BUFFER_BOUND={BUFFER_SIZE}"
47+
],
48+
49+
"OPT":
50+
[
51+
# Flag to access the static function of a file
52+
"--export-file-local-symbols"
4753
]
4854
}

test/cbmc/proofs/ProcessDHCPReplies/ProcessDHCPReplies_harness.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,34 @@
1313
#include "FreeRTOS_UDP_IP.h"
1414
#include "FreeRTOS_DHCP.h"
1515
#include "FreeRTOS_ARP.h"
16-
16+
#include "FreeRTOS_Routing.h"
1717

1818
/****************************************************************
1919
* Signature of function under test
20+
* The function name (prvProcessDHCPReplies) is mangled due to the
21+
* use of a CBMC flag (--export-file-local-symbols) which allows us
22+
* to access this static function outside the source file in which
23+
* it is defined.
2024
****************************************************************/
21-
22-
BaseType_t prvProcessDHCPReplies( BaseType_t xExpectedMessageType );
25+
BaseType_t __CPROVER_file_local_FreeRTOS_DHCP_c_prvProcessDHCPReplies( BaseType_t xExpectedMessageType,
26+
NetworkEndPoint_t * pxEndPoint );
2327

2428
/****************************************************************
2529
* The proof for FreeRTOS_gethostbyname.
2630
****************************************************************/
27-
2831
void harness()
2932
{
3033
/* Omitting model of an unconstrained xDHCPData because xDHCPData is */
3134
/* the source of uninitialized data only on line 647 to set a */
3235
/* transaction id is an outgoing message */
3336

3437
BaseType_t xExpectedMessageType;
38+
NetworkEndPoint_t xEndPoint;
39+
40+
/* The function under test is a private (static) function called only by
41+
* the TCP stack. The stack asserts that the endpoint cannot be NULL
42+
* before the function under test is invoked. */
43+
NetworkEndPoint_t * pxEndPoint = &xEndPoint;
3544

36-
prvProcessDHCPReplies( xExpectedMessageType );
45+
__CPROVER_file_local_FreeRTOS_DHCP_c_prvProcessDHCPReplies( xExpectedMessageType, pxEndPoint );
3746
}

0 commit comments

Comments
 (0)