Skip to content

Commit

Permalink
Initialize dmac array to nulls (#5538)
Browse files Browse the repository at this point in the history
* Initialize dmac array to nulls

* Use std::cout for print before console is init.
  • Loading branch information
jp-bennett authored Dec 10, 2024
1 parent d0e3427 commit 0e3dae4
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/platform/portduino/PortduinoGlue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ void getMacAddr(uint8_t *dmac)
if (optionMac != nullptr && strlen(optionMac) > 0) {
if (strlen(optionMac) >= 12) {
MAC_from_string(optionMac, dmac);
std::cout << optionMac << std::endl;
} else {
uint32_t hwId = sscanf(optionMac, "%u", &hwId);
dmac[0] = 0x80;
Expand All @@ -98,7 +97,6 @@ void getMacAddr(uint8_t *dmac)
}
} else if (settingsStrings[mac_address].length() > 11) {
MAC_from_string(settingsStrings[mac_address], dmac);
std::cout << settingsStrings[mac_address] << std::endl;
exit;
} else {

Expand Down Expand Up @@ -203,14 +201,14 @@ void portduinoSetup()
}
}

uint8_t dmac[6];
uint8_t dmac[6] = {0};
getMacAddr(dmac);
if (dmac[0] == 0 && dmac[1] == 0 && dmac[2] == 0 && dmac[3] == 0 && dmac[4] == 0 && dmac[5] == 0) {
std::cout << "*** Blank MAC Address not allowed!" << std::endl;
std::cout << "Please set a MAC Address in config.yaml using either MACAddress or MACAddressSource." << std::endl;
exit(EXIT_FAILURE);
}
printBytes("MAC Address: ", dmac, 6);
std::cout << "MAC Address: " << std::hex << +dmac[0] << +dmac[1] << +dmac[2] << +dmac[3] << +dmac[4] << +dmac[5] << std::endl;
// Rather important to set this, if not running simulated.
randomSeed(time(NULL));

Expand Down Expand Up @@ -531,4 +529,4 @@ bool MAC_from_string(std::string mac_str, uint8_t *dmac)
} else {
return false;
}
}
}

0 comments on commit 0e3dae4

Please sign in to comment.