fix a lot of low level cppcheck warnings (#9623)
* simplify the observer pattern, since all the called functions are const getters. * use arduino macro over std: for numerical values and refactor local variables in drawScrollbar() * oh, so Cppcheck actually complained about const pointers not being const. * slowly getting out of ifdef hell * fix inkHUD warnings as well * last 2 check warnings * git checks should fail on low defects from now on
This commit is contained in:
co-authored by
GitHub
parent
32db70037d
commit
56fd9c7813
@@ -496,7 +496,7 @@ void portduinoSetup()
|
||||
randomSeed(time(NULL));
|
||||
|
||||
std::string defaultGpioChipName = gpioChipName + std::to_string(portduino_config.lora_default_gpiochip);
|
||||
for (auto i : portduino_config.all_pins) {
|
||||
for (const auto *i : portduino_config.all_pins) {
|
||||
if (i->enabled && i->pin > max_GPIO)
|
||||
max_GPIO = i->pin;
|
||||
}
|
||||
@@ -510,7 +510,7 @@ void portduinoSetup()
|
||||
|
||||
// Need to bind all the configured GPIO pins so they're not simulated
|
||||
// TODO: If one of these fails, we should log and terminate
|
||||
for (auto i : portduino_config.all_pins) {
|
||||
for (const auto *i : portduino_config.all_pins) {
|
||||
// In the case of a ch341 Lora device, we don't want to touch the system GPIO lines for Lora
|
||||
// Those GPIO are handled in our usermode driver instead.
|
||||
if (i->config_section == "Lora" && portduino_config.lora_spi_dev == "ch341") {
|
||||
@@ -572,7 +572,7 @@ void portduinoSetup()
|
||||
return;
|
||||
}
|
||||
|
||||
int initGPIOPin(int pinNum, const std::string gpioChipName, int line)
|
||||
int initGPIOPin(int pinNum, const std::string &gpioChipName, int line)
|
||||
{
|
||||
#ifdef PORTDUINO_LINUX_HARDWARE
|
||||
std::string gpio_name = "GPIO" + std::to_string(pinNum);
|
||||
@@ -643,7 +643,7 @@ bool loadConfig(const char *configPath)
|
||||
if (yamlConfig["Lora"]) {
|
||||
|
||||
if (yamlConfig["Lora"]["Module"]) {
|
||||
for (auto &loraModule : portduino_config.loraModules) {
|
||||
for (const auto &loraModule : portduino_config.loraModules) {
|
||||
if (yamlConfig["Lora"]["Module"].as<std::string>("") == loraModule.second) {
|
||||
portduino_config.lora_module = loraModule.first;
|
||||
break;
|
||||
@@ -777,7 +777,7 @@ bool loadConfig(const char *configPath)
|
||||
}
|
||||
if (yamlConfig["Display"]) {
|
||||
|
||||
for (auto &screen_name : portduino_config.screen_names) {
|
||||
for (const auto &screen_name : portduino_config.screen_names) {
|
||||
if (yamlConfig["Display"]["Panel"].as<std::string>("") == screen_name.second)
|
||||
portduino_config.displayPanel = screen_name.first;
|
||||
}
|
||||
@@ -907,7 +907,7 @@ bool loadConfig(const char *configPath)
|
||||
}
|
||||
if (checkConfigPort) {
|
||||
portduino_config.api_port = (yamlConfig["General"]["APIPort"]).as<int>(-1);
|
||||
if (portduino_config.api_port != -1 && portduino_config.api_port > 1023 && portduino_config.api_port < 65536) {
|
||||
if (portduino_config.api_port > 1023 && portduino_config.api_port < 65536) {
|
||||
TCPPort = (portduino_config.api_port);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user