Skip to content

Commit 3c7f2ab

Browse files
committed
lwip: Fixed count of udp iterations to reflect attempts
1 parent 81bedff commit 3c7f2ab

File tree

2 files changed

+2
-11
lines changed
  • features/FEATURE_LWIP/TESTS/mbedmicro-net

2 files changed

+2
-11
lines changed

features/FEATURE_LWIP/TESTS/mbedmicro-net/udp_echo/main.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,13 @@ int main() {
8989
SocketAddress udp_addr(ipbuf, port);
9090

9191
int success = 0;
92-
int i = 0;
93-
while (success < ECHO_LOOPS) {
9492
prep_buffer(uuid, uuid_len, tx_buffer, sizeof(tx_buffer));
93+
for (int i = 0; success < ECHO_LOOPS; i++) {
9594
const int ret = sock.sendto(udp_addr, tx_buffer, sizeof(tx_buffer));
9695
if (ret >= 0) {
9796
printf("[%02d] sent %d bytes - %.*s \n", i, ret, ret, tx_buffer);
9897
} else {
9998
printf("[%02d] Network error %d\n", i, ret);
100-
i++;
10199
continue;
102100
}
103101

@@ -107,7 +105,6 @@ int main() {
107105
printf("[%02d] recv %d bytes - %.*s \n", i, n, n, tx_buffer);
108106
} else {
109107
printf("[%02d] Network error %d\n", i, n);
110-
i++;
111108
continue;
112109
}
113110

@@ -117,7 +114,6 @@ int main() {
117114
success += 1;
118115

119116
printf("[%02d] success #%d\n", i, success);
120-
i++;
121117
continue;
122118
}
123119

features/FEATURE_LWIP/TESTS/mbedmicro-net/udp_echo_parallel/main.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ class Echo {
8686

8787
sock.set_timeout(MBED_CFG_UDP_CLIENT_ECHO_TIMEOUT);
8888

89-
int i = 0;
90-
while (success < ECHO_LOOPS) {
9189
prep_buffer(id, uuid_buffer, uuid_len, tx_buffer, sizeof(tx_buffer));
90+
for (int i = 0; success < ECHO_LOOPS; i++) {
9291
const int ret = sock.sendto(udp_addr, tx_buffer, sizeof(tx_buffer));
9392
if (ret >= 0) {
9493
iomutex.lock();
@@ -98,7 +97,6 @@ class Echo {
9897
iomutex.lock();
9998
printf("[ID:%01d][%02d] Network error %d\n", id, i, ret);
10099
iomutex.unlock();
101-
i++;
102100
continue;
103101
}
104102

@@ -112,7 +110,6 @@ class Echo {
112110
iomutex.lock();
113111
printf("[ID:%01d][%02d] Network error %d\n", id, i, n);
114112
iomutex.unlock();
115-
i++;
116113
continue;
117114
}
118115

@@ -123,8 +120,6 @@ class Echo {
123120
iomutex.lock();
124121
printf("[ID:%01d][%02d] success #%d\n", id, i, success);
125122
iomutex.unlock();
126-
127-
i++;
128123
continue;
129124
}
130125

0 commit comments

Comments
 (0)