Skip to content

Commit

Permalink
Fix to fix for schoolboy error in sockets examples. (#1040)
Browse files Browse the repository at this point in the history
Commit 2c2670b "fixed" a schoolboy error in the example; however it didn't, it introduced an even more schoolboy error.  That boy needs to be punished.

Strange thing, of course, is that it passed testing because (a) the transmitted string is small enough that the while() loop doesn't have to loop and (b) the value of the first parameter happens to remain unchanged despite the error.
  • Loading branch information
RobMeades authored Nov 8, 2023
1 parent a12674d commit 93608d2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions example/sockets/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ U_PORT_TEST_FUNCTION("[example]", "exampleSockets")
// and print the echo that comes back
uPortLog("Sending data...\n");
while ((x >= 0) && (txSize > 0)) {
x = uSockWrite(sock + (sizeof(message) - txSize),
message, txSize);
x = uSockWrite(sock, message + (sizeof(message) - txSize), txSize);
if (x > 0) {
txSize -= x;
}
Expand Down
3 changes: 1 addition & 2 deletions example/sockets/main_dtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,7 @@ U_PORT_TEST_FUNCTION("[example]", "exampleSocketsDtls")
// and print the echo that comes back
uPortLog("Sending data...\n");
while ((x >= 0) && (txSize > 0)) {
x = uSockWrite(sock + (sizeof(message) - txSize),
message, txSize);
x = uSockWrite(sock, message + (sizeof(message) - txSize), txSize);
if (x > 0) {
txSize -= x;
}
Expand Down
3 changes: 1 addition & 2 deletions example/sockets/main_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,7 @@ U_PORT_TEST_FUNCTION("[example]", "exampleSocketsTls")
// and print the echo that comes back
uPortLog("Sending data...\n");
while ((x >= 0) && (txSize > 0)) {
x = uSockWrite(sock + (sizeof(message) - txSize),
message, txSize);
x = uSockWrite(sock, message + (sizeof(message) - txSize), txSize);
if (x > 0) {
txSize -= x;
}
Expand Down

0 comments on commit 93608d2

Please sign in to comment.