Fix a couple of warnings (#6445)

* Fix a couple of warnings

* fix build error

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
Thomas Göttgens 2025-03-29 14:14:24 +01:00 committed by GitHub
parent 7df327664e
commit 3148e7277d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 26 additions and 23 deletions

View File

@ -533,6 +533,9 @@ Power::Power() : OSThread("Power")
{ {
statusHandler = {}; statusHandler = {};
low_voltage_counter = 0; low_voltage_counter = 0;
#if defined(ELECROW_ThinkNode_M1) || defined(POWER_CFG)
low_voltage_counter_led3 = 0;
#endif
#ifdef DEBUG_HEAP #ifdef DEBUG_HEAP
lastheap = memGet.getFreeHeap(); lastheap = memGet.getFreeHeap();
#endif #endif
@ -668,12 +671,12 @@ void Power::readPowerStatus()
int8_t batteryChargePercent = -1; int8_t batteryChargePercent = -1;
OptionalBool usbPowered = OptUnknown; OptionalBool usbPowered = OptUnknown;
OptionalBool hasBattery = OptUnknown; // These must be static because NRF_APM code doesn't run every time OptionalBool hasBattery = OptUnknown; // These must be static because NRF_APM code doesn't run every time
OptionalBool isCharging = OptUnknown; OptionalBool isChargingNow = OptUnknown;
if (batteryLevel) { if (batteryLevel) {
hasBattery = batteryLevel->isBatteryConnect() ? OptTrue : OptFalse; hasBattery = batteryLevel->isBatteryConnect() ? OptTrue : OptFalse;
usbPowered = batteryLevel->isVbusIn() ? OptTrue : OptFalse; usbPowered = batteryLevel->isVbusIn() ? OptTrue : OptFalse;
isCharging = batteryLevel->isCharging() ? OptTrue : OptFalse; isChargingNow = batteryLevel->isCharging() ? OptTrue : OptFalse;
if (hasBattery) { if (hasBattery) {
batteryVoltageMv = batteryLevel->getBattVoltage(); batteryVoltageMv = batteryLevel->getBattVoltage();
// If the AXP192 returns a valid battery percentage, use it // If the AXP192 returns a valid battery percentage, use it
@ -702,15 +705,15 @@ void Power::readPowerStatus()
// If changed to DISCONNECTED // If changed to DISCONNECTED
if (nrf_usb_state == NRFX_POWER_USB_STATE_DISCONNECTED) if (nrf_usb_state == NRFX_POWER_USB_STATE_DISCONNECTED)
isCharging = usbPowered = OptFalse; isChargingNow = usbPowered = OptFalse;
// If changed to CONNECTED / READY // If changed to CONNECTED / READY
else else
isCharging = usbPowered = OptTrue; isChargingNow = usbPowered = OptTrue;
#endif #endif
// Notify any status instances that are observing us // Notify any status instances that are observing us
const PowerStatus powerStatus2 = PowerStatus(hasBattery, usbPowered, isCharging, batteryVoltageMv, batteryChargePercent); const PowerStatus powerStatus2 = PowerStatus(hasBattery, usbPowered, isChargingNow, batteryVoltageMv, batteryChargePercent);
LOG_DEBUG("Battery: usbPower=%d, isCharging=%d, batMv=%d, batPct=%d", powerStatus2.getHasUSB(), powerStatus2.getIsCharging(), LOG_DEBUG("Battery: usbPower=%d, isCharging=%d, batMv=%d, batPct=%d", powerStatus2.getHasUSB(), powerStatus2.getIsCharging(),
powerStatus2.getBatteryVoltageMv(), powerStatus2.getBatteryChargePercent()); powerStatus2.getBatteryVoltageMv(), powerStatus2.getBatteryChargePercent());
#if defined(ELECROW_ThinkNode_M1) || defined(POWER_CFG) #if defined(ELECROW_ThinkNode_M1) || defined(POWER_CFG)

View File

@ -983,13 +983,14 @@ void GPS::down()
else { else {
// Check whether the GPS hardware is capable of GPS_SOFTSLEEP // Check whether the GPS hardware is capable of GPS_SOFTSLEEP
// If not, fallback to GPS_HARDSLEEP instead // If not, fallback to GPS_HARDSLEEP instead
#ifdef PIN_GPS_STANDBY // L76B, L76K and clones have a standby pin
bool softsleepSupported = true;
#else
bool softsleepSupported = false; bool softsleepSupported = false;
#endif
// U-blox is supported via PMREQ // U-blox is supported via PMREQ
if (IS_ONE_OF(gnssModel, GNSS_MODEL_UBLOX6, GNSS_MODEL_UBLOX7, GNSS_MODEL_UBLOX8, GNSS_MODEL_UBLOX9, GNSS_MODEL_UBLOX10)) if (IS_ONE_OF(gnssModel, GNSS_MODEL_UBLOX6, GNSS_MODEL_UBLOX7, GNSS_MODEL_UBLOX8, GNSS_MODEL_UBLOX9, GNSS_MODEL_UBLOX10))
softsleepSupported = true; softsleepSupported = true;
#ifdef PIN_GPS_STANDBY // L76B, L76K and clones have a standby pin
softsleepSupported = true;
#endif
if (softsleepSupported) { if (softsleepSupported) {
// How long does gps_update_interval need to be, for GPS_HARDSLEEP to become more efficient than // How long does gps_update_interval need to be, for GPS_HARDSLEEP to become more efficient than

View File

@ -1061,8 +1061,8 @@ void NodeDB::loadFromDisk()
// if (state != LoadFileResult::LOAD_SUCCESS) { // if (state != LoadFileResult::LOAD_SUCCESS) {
// installDefaultDeviceState(); // Our in RAM copy might now be corrupt // installDefaultDeviceState(); // Our in RAM copy might now be corrupt
//} else { //} else {
if (devicestate.version < DEVICESTATE_MIN_VER) { if ((state != LoadFileResult::LOAD_SUCCESS) || (devicestate.version < DEVICESTATE_MIN_VER)) {
LOG_WARN("Devicestate %d is old, discard", devicestate.version); LOG_WARN("Devicestate %d is old or invalid, discard", devicestate.version);
installDefaultDeviceState(); installDefaultDeviceState();
} else { } else {
LOG_INFO("Loaded saved devicestate version %d", devicestate.version); LOG_INFO("Loaded saved devicestate version %d", devicestate.version);

View File

@ -188,7 +188,7 @@ ErrorCode Router::sendLocal(meshtastic_MeshPacket *p, RxSource src)
// don't override if a channel was requested and no need to set it when PKI is enforced // don't override if a channel was requested and no need to set it when PKI is enforced
if (!p->channel && !p->pki_encrypted && !isBroadcast(p->to)) { if (!p->channel && !p->pki_encrypted && !isBroadcast(p->to)) {
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(p->to); meshtastic_NodeInfoLite const *node = nodeDB->getMeshNode(p->to);
if (node) { if (node) {
p->channel = node->channel; p->channel = node->channel;
LOG_DEBUG("localSend to channel %d", p->channel); LOG_DEBUG("localSend to channel %d", p->channel);
@ -688,7 +688,7 @@ void Router::perhapsHandleReceived(meshtastic_MeshPacket *p)
return; return;
} }
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(p->from); meshtastic_NodeInfoLite const *node = nodeDB->getMeshNode(p->from);
if (node != NULL && node->is_ignored) { if (node != NULL && node->is_ignored) {
LOG_DEBUG("Ignore msg, 0x%x is ignored", p->from); LOG_DEBUG("Ignore msg, 0x%x is ignored", p->from);
packetPool.release(p); packetPool.release(p);

View File

@ -37,7 +37,7 @@ class STM32_LittleFS
{ {
public: public:
STM32_LittleFS(void); STM32_LittleFS(void);
STM32_LittleFS(struct lfs_config *cfg); explicit STM32_LittleFS(struct lfs_config *cfg);
virtual ~STM32_LittleFS(); virtual ~STM32_LittleFS();
bool begin(struct lfs_config *cfg = NULL); bool begin(struct lfs_config *cfg = NULL);

View File

@ -217,9 +217,9 @@ int File::available(void)
_fs->_lockFS(); _fs->_lockFS();
if (!this->_is_dir) { if (!this->_is_dir) {
uint32_t size = lfs_file_size(_fs->_getFS(), _file); uint32_t file_size = lfs_file_size(_fs->_getFS(), _file);
uint32_t pos = lfs_file_tell(_fs->_getFS(), _file); uint32_t pos = lfs_file_tell(_fs->_getFS(), _file);
ret = size - pos; ret = file_size - pos;
} }
_fs->_unlockFS(); _fs->_unlockFS();
@ -279,10 +279,9 @@ bool File::truncate(uint32_t pos)
bool File::truncate(void) bool File::truncate(void)
{ {
int32_t ret = LFS_ERR_ISDIR; int32_t ret = LFS_ERR_ISDIR;
uint32_t pos;
_fs->_lockFS(); _fs->_lockFS();
if (!this->_is_dir) { if (!this->_is_dir) {
pos = lfs_file_tell(_fs->_getFS(), _file); uint32_t pos = lfs_file_tell(_fs->_getFS(), _file);
ret = lfs_file_truncate(_fs->_getFS(), _file, pos); ret = lfs_file_truncate(_fs->_getFS(), _file, pos);
} }
_fs->_unlockFS(); _fs->_unlockFS();

View File

@ -42,7 +42,7 @@ enum {
class File : public Stream class File : public Stream
{ {
public: public:
File(STM32_LittleFS &fs); explicit File(STM32_LittleFS &fs);
File(char const *filename, uint8_t mode, STM32_LittleFS &fs); File(char const *filename, uint8_t mode, STM32_LittleFS &fs);
public: public:

View File

@ -863,7 +863,7 @@ static int lfs_dir_find(lfs_t *lfs, lfs_dir_t *dir, lfs_entry_t *entry, const ch
// check that entry has not been moved // check that entry has not been moved
if (entry->d.type & 0x80) { if (entry->d.type & 0x80) {
int moved = lfs_moved(lfs, &entry->d.u); int moved = lfs_moved(lfs, &entry->d.u);
if (moved < 0 || moved) { if (moved) {
return (moved < 0) ? moved : LFS_ERR_NOENT; return (moved < 0) ? moved : LFS_ERR_NOENT;
} }
@ -1057,7 +1057,7 @@ int lfs_dir_seek(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off)
return 0; return 0;
} }
lfs_soff_t lfs_dir_tell(lfs_t *lfs, lfs_dir_t *dir) lfs_soff_t lfs_dir_tell(lfs_t *lfs, lfs_dir_t const *dir)
{ {
(void)lfs; (void)lfs;
return dir->pos; return dir->pos;
@ -1755,7 +1755,7 @@ int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size)
return 0; return 0;
} }
lfs_soff_t lfs_file_tell(lfs_t *lfs, lfs_file_t *file) lfs_soff_t lfs_file_tell(lfs_t *lfs, lfs_file_t const *file)
{ {
(void)lfs; (void)lfs;
return file->pos; return file->pos;