Skip to content

Commit 34e0d69

Browse files
committed
Replace some portTICK_PERIOD_MS usages in tests
Use safer pdMS_TO_TICKS() macro instead. Keep some portTICK_PERIOD_MS usages to test both implementations.
1 parent 9440795 commit 34e0d69

File tree

33 files changed

+101
-138
lines changed

33 files changed

+101
-138
lines changed

test/Coverity/ConfigFiles/FreeRTOSIPConfig.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,9 @@
116116
* maximum allowable send block time prevents prevents a deadlock occurring when
117117
* all the network buffers are in use and the tasks that process (and subsequently
118118
* free) the network buffers are themselves blocked waiting for a network buffer.
119-
* ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
120-
* milliseconds can be converted to a time in ticks by dividing the time in
121-
* milliseconds by portTICK_PERIOD_MS. */
122-
#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000U / portTICK_PERIOD_MS )
119+
* ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
120+
* milliseconds can be converted to a time in ticks using pdMS_TO_TICKS().*/
121+
#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS pdMS_TO_TICKS( 5000U )
123122

124123
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
125124
* address, netmask, DNS server address and gateway address from a DHCP server. If
@@ -144,8 +143,7 @@
144143
* static IP address passed as a parameter to FreeRTOS_IPInit() if the
145144
* re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
146145
* a DHCP reply being received. */
147-
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD \
148-
( 120000U / portTICK_PERIOD_MS )
146+
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD pdMS_TO_TICKS( 120000U )
149147

150148
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
151149
* stack can only send a UDP message to a remove IP address if it knowns the MAC

test/build-combination/AllDisable/FreeRTOSIPConfig.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,9 @@
112112
* maximum allowable send block time prevents prevents a deadlock occurring when
113113
* all the network buffers are in use and the tasks that process (and subsequently
114114
* free) the network buffers are themselves blocked waiting for a network buffer.
115-
* ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
116-
* milliseconds can be converted to a time in ticks by dividing the time in
117-
* milliseconds by portTICK_PERIOD_MS. */
118-
#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000U / portTICK_PERIOD_MS )
115+
* ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
116+
* milliseconds can be converted to a time in ticks using pdMS_TO_TICKS().*/
117+
#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS pdMS_TO_TICKS( 5000U )
119118

120119
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
121120
* address, netmask, DNS server address and gateway address from a DHCP server. If

test/build-combination/AllEnable/FreeRTOSIPConfig.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,9 @@
143143
* maximum allowable send block time prevents prevents a deadlock occurring when
144144
* all the network buffers are in use and the tasks that process (and subsequently
145145
* free) the network buffers are themselves blocked waiting for a network buffer.
146-
* ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
147-
* milliseconds can be converted to a time in ticks by dividing the time in
148-
* milliseconds by portTICK_PERIOD_MS. */
149-
#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000U / portTICK_PERIOD_MS )
146+
* ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
147+
* milliseconds can be converted to a time in ticks using pdMS_TO_TICKS().*/
148+
#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS pdMS_TO_TICKS( 5000U )
150149

151150
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
152151
* address, netmask, DNS server address and gateway address from a DHCP server. If
@@ -171,8 +170,7 @@
171170
* static IP address passed as a parameter to FreeRTOS_IPInit() if the
172171
* re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
173172
* a DHCP reply being received. */
174-
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD \
175-
( 120000U / portTICK_PERIOD_MS )
173+
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD pdMS_TO_TICKS( 120000U )
176174

177175
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
178176
* stack can only send a UDP message to a remove IP address if it knowns the MAC
@@ -287,7 +285,7 @@
287285

288286
/* The windows simulator cannot really simulate MAC interrupts, and needs to
289287
* block occasionally to allow other tasks to run. */
290-
#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
288+
#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY pdMS_TO_TICKS( 20 )
291289

292290
/* Advanced only: in order to access 32-bit fields in the IP packets with
293291
* 32-bit memory instructions, all packets will be stored 32-bit-aligned,

test/build-combination/Enable_IPv4/FreeRTOSIPConfig.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,9 @@
146146
* maximum allowable send block time prevents prevents a deadlock occurring when
147147
* all the network buffers are in use and the tasks that process (and subsequently
148148
* free) the network buffers are themselves blocked waiting for a network buffer.
149-
* ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
150-
* milliseconds can be converted to a time in ticks by dividing the time in
151-
* milliseconds by portTICK_PERIOD_MS. */
152-
#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000U / portTICK_PERIOD_MS )
149+
* ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
150+
* milliseconds can be converted to a time in ticks using pdMS_TO_TICKS().*/
151+
#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS pdMS_TO_TICKS( 5000U )
153152

154153
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
155154
* address, netmask, DNS server address and gateway address from a DHCP server. If
@@ -174,8 +173,7 @@
174173
* static IP address passed as a parameter to FreeRTOS_IPInit() if the
175174
* re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
176175
* a DHCP reply being received. */
177-
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD \
178-
( 120000U / portTICK_PERIOD_MS )
176+
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD pdMS_TO_TICKS( 120000U )
179177

180178
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
181179
* stack can only send a UDP message to a remove IP address if it knowns the MAC
@@ -290,7 +288,7 @@
290288

291289
/* The windows simulator cannot really simulate MAC interrupts, and needs to
292290
* block occasionally to allow other tasks to run. */
293-
#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
291+
#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY pdMS_TO_TICKS( 20 )
294292

295293
/* Advanced only: in order to access 32-bit fields in the IP packets with
296294
* 32-bit memory instructions, all packets will be stored 32-bit-aligned,

test/build-combination/Enable_IPv4_IPv6/FreeRTOSIPConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@
290290

291291
/* The windows simulator cannot really simulate MAC interrupts, and needs to
292292
* block occasionally to allow other tasks to run. */
293-
#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
293+
#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY pdMS_TO_TICKS( 20 )
294294

295295
/* Advanced only: in order to access 32-bit fields in the IP packets with
296296
* 32-bit memory instructions, all packets will be stored 32-bit-aligned,

test/build-combination/Enable_IPv4_TCP/FreeRTOSIPConfig.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,9 @@
146146
* maximum allowable send block time prevents prevents a deadlock occurring when
147147
* all the network buffers are in use and the tasks that process (and subsequently
148148
* free) the network buffers are themselves blocked waiting for a network buffer.
149-
* ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
150-
* milliseconds can be converted to a time in ticks by dividing the time in
151-
* milliseconds by portTICK_PERIOD_MS. */
152-
#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000U / portTICK_PERIOD_MS )
149+
* ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
150+
* milliseconds can be converted to a time in ticks using pdMS_TO_TICKS().*/
151+
#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS pdMS_TO_TICKS( 5000U )
153152

154153
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
155154
* address, netmask, DNS server address and gateway address from a DHCP server. If
@@ -174,8 +173,7 @@
174173
* static IP address passed as a parameter to FreeRTOS_IPInit() if the
175174
* re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
176175
* a DHCP reply being received. */
177-
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD \
178-
( 120000U / portTICK_PERIOD_MS )
176+
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD pdMS_TO_TICKS( 120000U )
179177

180178
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
181179
* stack can only send a UDP message to a remove IP address if it knowns the MAC

test/build-combination/Enable_IPv6/FreeRTOSIPConfig.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@
174174
* static IP address passed as a parameter to FreeRTOS_IPInit() if the
175175
* re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
176176
* a DHCP reply being received. */
177-
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD \
178-
( 120000U / portTICK_PERIOD_MS )
177+
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD pdMS_TO_TICKS( 120000U )
179178

180179
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
181180
* stack can only send a UDP message to a remove IP address if it knowns the MAC
@@ -290,7 +289,7 @@
290289

291290
/* The windows simulator cannot really simulate MAC interrupts, and needs to
292291
* block occasionally to allow other tasks to run. */
293-
#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
292+
#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY pdMS_TO_TICKS( 20 )
294293

295294
/* Advanced only: in order to access 32-bit fields in the IP packets with
296295
* 32-bit memory instructions, all packets will be stored 32-bit-aligned,

test/build-combination/Enable_IPv6_TCP/FreeRTOSIPConfig.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@
174174
* static IP address passed as a parameter to FreeRTOS_IPInit() if the
175175
* re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
176176
* a DHCP reply being received. */
177-
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD \
178-
( 120000U / portTICK_PERIOD_MS )
177+
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD pdMS_TO_TICKS( 120000U )
179178

180179
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
181180
* stack can only send a UDP message to a remove IP address if it knowns the MAC
@@ -290,7 +289,7 @@
290289

291290
/* The windows simulator cannot really simulate MAC interrupts, and needs to
292291
* block occasionally to allow other tasks to run. */
293-
#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
292+
#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY pdMS_TO_TICKS( 20 )
294293

295294
/* Advanced only: in order to access 32-bit fields in the IP packets with
296295
* 32-bit memory instructions, all packets will be stored 32-bit-aligned,

test/build-combination/Header_Self_Contain/FreeRTOSIPConfig.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,9 @@
142142
* maximum allowable send block time prevents prevents a deadlock occurring when
143143
* all the network buffers are in use and the tasks that process (and subsequently
144144
* free) the network buffers are themselves blocked waiting for a network buffer.
145-
* ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
146-
* milliseconds can be converted to a time in ticks by dividing the time in
147-
* milliseconds by portTICK_PERIOD_MS. */
148-
#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000U / portTICK_PERIOD_MS )
145+
* ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
146+
* milliseconds can be converted to a time in ticks using pdMS_TO_TICKS().*/
147+
#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS pdMS_TO_TICKS( 5000U )
149148

150149
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
151150
* address, netmask, DNS server address and gateway address from a DHCP server. If
@@ -170,8 +169,7 @@
170169
* static IP address passed as a parameter to FreeRTOS_IPInit() if the
171170
* re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
172171
* a DHCP reply being received. */
173-
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD \
174-
( 120000U / portTICK_PERIOD_MS )
172+
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD pdMS_TO_TICKS( 120000U )
175173

176174
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
177175
* stack can only send a UDP message to a remove IP address if it knowns the MAC

test/cbmc/patches/FreeRTOSIPConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@
269269

270270
/* The windows simulator cannot really simulate MAC interrupts, and needs to
271271
* block occasionally to allow other tasks to run. */
272-
#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
272+
#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY pdMS_TO_TICKS( 20 )
273273

274274
/* Advanced only: in order to access 32-bit fields in the IP packets with
275275
* 32-bit memory instructions, all packets will be stored 32-bit-aligned,

0 commit comments

Comments
 (0)