Skip to content

Commit

Permalink
Removed usage of GOTO in WifiClient.cpp (#228)
Browse files Browse the repository at this point in the history
* Removed GOTO

Couldn't help myself

* Coding style

* Small coding style oversight

Why am I wasting time.
  • Loading branch information
gloglas authored May 21, 2024
1 parent f746876 commit 0ddb7c1
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions Arduino_package/hardware/libraries/WiFi/src/WiFiClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,24 @@ uint8_t WiFiClient::connected() {
}

int WiFiClient::available() {
int ret = 0;
int err;

if (!_is_connected) {
if (!_is_connected || _sock < 0) {
return 0;
}
if (_sock >= 0) {
try_again:
ret = clientdrv.availData(_sock);
if (ret > 0) {

while(true){
if (clientdrv.availData(_sock) > 0) {
return 1;
} else {
err = clientdrv.getLastErrno(_sock);
int err = clientdrv.getLastErrno(_sock);
if (err == EAGAIN) {
goto try_again;
continue;
}
if (err != 0) {
_is_connected = false;
}
return 0;
}
}

return 0;
}

int WiFiClient::read() {
Expand Down

0 comments on commit 0ddb7c1

Please sign in to comment.