Skip to content

Commit

Permalink
add nullptr check, however...
Browse files Browse the repository at this point in the history
this is just a good practice but in practice eth_if cannot be ever nullprt
  • Loading branch information
maidnl committed Jun 17, 2024
1 parent 0108ded commit 0ae67aa
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libraries/Ethernet/src/Ethernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPA
}

int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet, unsigned long timeout, unsigned long responseTimeout) {
if(eth_if == nullptr) {
return 0;
}

config(ip, dns, gateway, subnet);

eth_if->set_dhcp(false);
Expand All @@ -68,6 +72,9 @@ void arduino::EthernetClass::end() {
}

EthernetLinkStatus arduino::EthernetClass::linkStatus() {
if(eth_if == nullptr) {
return LinkOFF;
}
return (eth_if->get_connection_status() == NSAPI_STATUS_GLOBAL_UP ? LinkON : LinkOFF);
}

Expand All @@ -77,7 +84,9 @@ EthernetHardwareStatus arduino::EthernetClass::hardwareStatus() {


int arduino::EthernetClass::disconnect() {
eth_if->disconnect();
if(eth_if != nullptr) {
eth_if->disconnect();
}
return 1;
}

Expand Down

0 comments on commit 0ae67aa

Please sign in to comment.