more warning fixes

1.2-legacy
Mike Kinney 2022-01-24 18:39:17 +00:00
rodzic caaa235c5d
commit 7c362af3de
27 zmienionych plików z 74 dodań i 69 usunięć

Wyświetl plik

@ -42,7 +42,7 @@ class GPSStatus : public Status
}
// preferred method
GPSStatus(bool hasLock, bool isConnected, Position pos)
GPSStatus(bool hasLock, bool isConnected, const Position& pos)
: Status()
{
this->hasLock = hasLock;
@ -149,4 +149,4 @@ class GPSStatus : public Status
} // namespace meshtastic
extern meshtastic::GPSStatus *gpsStatus;
extern meshtastic::GPSStatus *gpsStatus;

Wyświetl plik

@ -235,18 +235,18 @@ void Power::readPowerStatus()
}
// Notify any status instances that are observing us
const PowerStatus powerStatus =
const PowerStatus powerStatus2 =
PowerStatus(hasBattery ? OptTrue : OptFalse, batteryLevel->isVBUSPlug() ? OptTrue : OptFalse,
batteryLevel->isChargeing() ? OptTrue : OptFalse, batteryVoltageMv, batteryChargePercent);
DEBUG_MSG("Battery: usbPower=%d, isCharging=%d, batMv=%d, batPct=%d\n", powerStatus.getHasUSB(),
powerStatus.getIsCharging(), powerStatus.getBatteryVoltageMv(), powerStatus.getBatteryChargePercent());
newStatus.notifyObservers(&powerStatus);
DEBUG_MSG("Battery: usbPower=%d, isCharging=%d, batMv=%d, batPct=%d\n", powerStatus2.getHasUSB(),
powerStatus2.getIsCharging(), powerStatus2.getBatteryVoltageMv(), powerStatus2.getBatteryChargePercent());
newStatus.notifyObservers(&powerStatus2);
// If we have a battery at all and it is less than 10% full, force deep sleep if we have more than 3 low readings in a row
// Supect fluctuating voltage on the RAK4631 to force it to deep sleep even if battery is at 85% after only a few days
#ifdef NRF52_SERIES
if (powerStatus.getHasBattery() && !powerStatus.getHasUSB()){
if (powerStatus2.getHasBattery() && !powerStatus2.getHasUSB()){
if (batteryLevel->getBattVoltage() < MIN_BAT_MILLIVOLTS){
low_voltage_counter++;
if (low_voltage_counter>3)
@ -257,13 +257,13 @@ void Power::readPowerStatus()
}
#else
// If we have a battery at all and it is less than 10% full, force deep sleep
if (powerStatus.getHasBattery() && !powerStatus.getHasUSB() && batteryLevel->getBattVoltage() < MIN_BAT_MILLIVOLTS)
if (powerStatus2.getHasBattery() && !powerStatus2.getHasUSB() && batteryLevel->getBattVoltage() < MIN_BAT_MILLIVOLTS)
powerFSM.trigger(EVENT_LOW_BATTERY);
#endif
} else {
// No power sensing on this board - tell everyone else we have no idea what is happening
const PowerStatus powerStatus = PowerStatus(OptUnknown, OptUnknown, OptUnknown, -1, -1);
newStatus.notifyObservers(&powerStatus);
const PowerStatus powerStatus3 = PowerStatus(OptUnknown, OptUnknown, OptUnknown, -1, -1);
newStatus.notifyObservers(&powerStatus3);
}
}

Wyświetl plik

@ -63,7 +63,7 @@ static void lsIdle()
// DEBUG_MSG("lsIdle begin ls_secs=%u\n", getPref_ls_secs());
#ifndef NO_ESP32
esp_sleep_source_t wakeCause = ESP_SLEEP_WAKEUP_UNDEFINED;
esp_sleep_source_t wakeCause2 = ESP_SLEEP_WAKEUP_UNDEFINED;
// Do we have more sleeping to do?
if (secsSlept < getPref_ls_secs()) {
@ -73,14 +73,14 @@ static void lsIdle()
// If some other service would stall sleep, don't let sleep happen yet
if (doPreflightSleep()) {
setLed(false); // Never leave led on while in light sleep
wakeCause = doLightSleep(sleepTime * 1000LL);
wakeCause2 = doLightSleep(sleepTime * 1000LL);
switch (wakeCause) {
switch (wakeCause2) {
case ESP_SLEEP_WAKEUP_TIMER:
// Normal case: timer expired, we should just go back to sleep ASAP
setLed(true); // briefly turn on led
wakeCause = doLightSleep(1); // leave led on for 1ms
wakeCause2 = doLightSleep(1); // leave led on for 1ms
secsSlept += sleepTime;
// DEBUG_MSG("sleeping, flash led!\n");
@ -94,7 +94,7 @@ static void lsIdle()
default:
// We woke for some other reason (button press, device interrupt)
// uint64_t status = esp_sleep_get_ext1_wakeup_status();
DEBUG_MSG("wakeCause %d\n", wakeCause);
DEBUG_MSG("wakeCause2 %d\n", wakeCause2);
#ifdef BUTTON_PIN
bool pressed = !digitalRead(BUTTON_PIN);

Wyświetl plik

@ -117,8 +117,7 @@ float AirTime::utilizationTXPercent()
return (float(sum) / float(MS_IN_HOUR)) * 100;
}
AirTime::AirTime() : concurrency::OSThread("AirTime") {
airtimes = {};
AirTime::AirTime() : concurrency::OSThread("AirTime"),airtimes({}) {
}
int32_t AirTime::runOnce()

Wyświetl plik

@ -7,9 +7,8 @@
namespace concurrency
{
BinarySemaphoreFreeRTOS::BinarySemaphoreFreeRTOS()
BinarySemaphoreFreeRTOS::BinarySemaphoreFreeRTOS() : semaphore(xSemaphoreCreateBinary())
{
semaphore = xSemaphoreCreateBinary();
assert(semaphore);
}
@ -38,4 +37,4 @@ IRAM_ATTR void BinarySemaphoreFreeRTOS::giveFromISR(BaseType_t *pxHigherPriority
} // namespace concurrency
#endif
#endif

Wyświetl plik

@ -6,9 +6,8 @@ namespace concurrency
{
#ifdef HAS_FREE_RTOS
Lock::Lock()
Lock::Lock() : handle(xSemaphoreCreateBinary())
{
handle = xSemaphoreCreateBinary();
assert(handle);
assert(xSemaphoreGive(handle));
}

Wyświetl plik

@ -11,10 +11,10 @@ class Air530GPS : public NMEAGPS
{
protected:
/// If possible force the GPS into sleep/low power mode
virtual void sleep();
virtual void sleep() override;
/// wake the GPS into normal operation mode
virtual void wake();
virtual void wake() override;
private:
/// Send a NMEA cmd with checksum

Wyświetl plik

@ -171,7 +171,7 @@ void GeoCoord::latLongToMGRS(const double lat, const double lon, MGRS &mgrs) {
* Based on: https://www.movable-type.co.uk/scripts/latlong-os-gridref.html
*/
void GeoCoord::latLongToOSGR(const double lat, const double lon, OSGR &osgr) {
char letter[] = "ABCDEFGHJKLMNOPQRSTUVWXYZ"; // No 'I' in OSGR
const char letter[] = "ABCDEFGHJKLMNOPQRSTUVWXYZ"; // No 'I' in OSGR
double a = 6377563.396; // Airy 1830 semi-major axis
double b = 6356256.909; // Airy 1830 semi-minor axis
double f0 = 0.9996012717; // National Grid point scale factor on the central meridian
@ -419,12 +419,12 @@ float GeoCoord::rangeRadiansToMeters(double range_radians) {
}
// Find distance from point to passed in point
int32_t GeoCoord::distanceTo(GeoCoord pointB) {
int32_t GeoCoord::distanceTo(const GeoCoord& pointB) {
return latLongToMeter(this->getLatitude() * 1e-7, this->getLongitude() * 1e-7, pointB.getLatitude() * 1e-7, pointB.getLongitude() * 1e-7);
}
// Find bearing from point to passed in point
int32_t GeoCoord::bearingTo(GeoCoord pointB) {
int32_t GeoCoord::bearingTo(const GeoCoord& pointB) {
return bearing(this->getLatitude() * 1e-7, this->getLongitude() * 1e-7, pointB.getLatitude() * 1e-7, pointB.getLongitude() * 1e-7);
}

Wyświetl plik

@ -119,8 +119,8 @@ class GeoCoord {
static float rangeMetersToRadians(double range_meters);
// Point to point conversions
int32_t distanceTo(GeoCoord pointB);
int32_t bearingTo(GeoCoord pointB);
int32_t distanceTo(const GeoCoord& pointB);
int32_t bearingTo(const GeoCoord& pointB);
std::shared_ptr<GeoCoord> pointAtDistance(double bearing, double range);
// Lat lon alt getters

Wyświetl plik

@ -54,7 +54,7 @@ class UBloxGPS : public GPS
* @return true if we've acquired a new location
*/
virtual bool lookForLocation() override;
virtual bool hasLock();
virtual bool hasLock() override;
/// If possible force the GPS into sleep/low power mode
virtual void sleep() override;

Wyświetl plik

@ -651,7 +651,6 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
static char distStr[20];
strcpy(distStr, "? km"); // might not have location data
float headingRadian;
NodeInfo *ourNode = nodeDB.getNode(nodeDB.getNodeNum());
const char *fields[] = {username, distStr, signalStr, lastStr, NULL};
@ -679,7 +678,7 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
// it. currently we don't do this and instead draw north up only.
float bearingToOther =
GeoCoord::bearing(DegD(p.latitude_i), DegD(p.longitude_i), DegD(op.latitude_i), DegD(op.longitude_i));
headingRadian = bearingToOther - myHeading;
float headingRadian = bearingToOther - myHeading;
drawNodeHeading(display, compassX, compassY, headingRadian);
}
}
@ -943,20 +942,20 @@ int32_t Screen::runOnce()
void Screen::drawDebugInfoTrampoline(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{
Screen *screen = reinterpret_cast<Screen *>(state->userData);
screen->debugInfo.drawFrame(display, state, x, y);
Screen *screen2 = reinterpret_cast<Screen *>(state->userData);
screen2->debugInfo.drawFrame(display, state, x, y);
}
void Screen::drawDebugInfoSettingsTrampoline(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{
Screen *screen = reinterpret_cast<Screen *>(state->userData);
screen->debugInfo.drawFrameSettings(display, state, x, y);
Screen *screen2 = reinterpret_cast<Screen *>(state->userData);
screen2->debugInfo.drawFrameSettings(display, state, x, y);
}
void Screen::drawDebugInfoWiFiTrampoline(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{
Screen *screen = reinterpret_cast<Screen *>(state->userData);
screen->debugInfo.drawFrameWiFi(display, state, x, y);
Screen *screen2 = reinterpret_cast<Screen *>(state->userData);
screen2->debugInfo.drawFrameWiFi(display, state, x, y);
}
/* show a message that the SSL cert is being built

Wyświetl plik

@ -22,7 +22,7 @@ class RotaryEncoderInterruptBase :
private concurrency::OSThread
{
public:
RotaryEncoderInterruptBase(
explicit RotaryEncoderInterruptBase(
const char *name);
void init(
uint8_t pinA, uint8_t pinB, uint8_t pinPress,

Wyświetl plik

@ -247,7 +247,7 @@ static int mem_test(uint32_t *_start, size_t len, bool doRead = true, bool doWri
{
volatile uint32_t *addr;
volatile uint32_t *start = (volatile uint32_t *)_start;
volatile uint32_t *end = start + len / sizeof(uint32_t);
const volatile uint32_t *end = start + len / sizeof(uint32_t);
uint32_t pattern = 0;
uint32_t val;
uint32_t readback;
@ -315,4 +315,4 @@ void doMemTest()
assert(0); // FIXME report error better
iter++;
}
}

Wyświetl plik

@ -102,7 +102,7 @@ void Channels::initDefaultChannel(ChannelIndex chIndex)
CryptoKey Channels::getKey(ChannelIndex chIndex)
{
Channel &ch = getByIndex(chIndex);
ChannelSettings &channelSettings = ch.settings;
const ChannelSettings &channelSettings = ch.settings;
assert(ch.has_settings);
CryptoKey k;
@ -206,7 +206,7 @@ void Channels::setChannel(const Channel &c)
const char *Channels::getName(size_t chIndex)
{
// Convert the short "" representation for Default into a usable string
ChannelSettings &channelSettings = getByIndex(chIndex).settings;
const ChannelSettings &channelSettings = getByIndex(chIndex).settings;
const char *channelName = channelSettings.name;
if (!*channelName) { // emptystring
// Per mesh.proto spec, if bandwidth is specified we must ignore modemConfig enum, we assume that in that case

Wyświetl plik

@ -26,9 +26,12 @@ class Channels
ChannelIndex activeChannelIndex = 0;
/// the precomputed hashes for each of our channels, or -1 for invalid
int16_t hashes[MAX_NUM_CHANNELS];
int16_t hashes[MAX_NUM_CHANNELS] = {};
public:
Channels() {}
/// Well known channel names
static const char *adminChannel, *gpioChannel, *serialChannel;
@ -134,4 +137,4 @@ class Channels
};
/// Singleton channel table
extern Channels channels;
extern Channels channels;

Wyświetl plik

@ -18,7 +18,7 @@ class MeshPacketQueue
bool replaceLowerPriorityPacket(MeshPacket *mp);
public:
MeshPacketQueue(size_t _maxLen);
explicit MeshPacketQueue(size_t _maxLen);
/** enqueue a packet, return false if full */
bool enqueue(MeshPacket *p);
@ -30,4 +30,4 @@ class MeshPacketQueue
/** Attempt to find and remove a packet from this queue. Returns the packet which was removed from the queue */
MeshPacket *remove(NodeNum from, PacketId id);
};
};

Wyświetl plik

@ -16,7 +16,7 @@ class RadioLibRF95: public SX1278 {
\param mod Instance of Module that will be used to communicate with the %LoRa chip.
*/
RadioLibRF95(Module* mod);
explicit RadioLibRF95(Module* mod);
// basic methods

Wyświetl plik

@ -13,7 +13,7 @@ struct GlobalPacketId {
bool operator==(const GlobalPacketId &p) const { return node == p.node && id == p.id; }
GlobalPacketId(const MeshPacket *p)
explicit GlobalPacketId(const MeshPacket *p)
{
node = getFrom(p);
id = p->id;
@ -45,7 +45,7 @@ struct PendingPacket {
bool wantRoute = false;
PendingPacket() {}
PendingPacket(MeshPacket *p);
explicit PendingPacket(MeshPacket *p);
};
class GlobalPacketIdHashFunction

Wyświetl plik

@ -19,9 +19,8 @@ template <class T> class TypedQueue
concurrency::OSThread *reader = NULL;
public:
explicit TypedQueue(int maxElements)
explicit TypedQueue(int maxElements) : h(xQueueCreate(maxElements, sizeof(T)))
{
h = xQueueCreate(maxElements, sizeof(T));
assert(h);
}

Wyświetl plik

@ -130,8 +130,8 @@ static void taskCreateCert(void *parameter)
void createSSLCert()
{
bool runLoop = false;
if (isWifiAvailable() && !isCertReady) {
bool runLoop = false;
// Create a new process just to handle creating the cert.
// This is a workaround for Bug: https://github.com/fhessel/esp32_https_server/issues/48

Wyświetl plik

@ -13,7 +13,7 @@ class WiFiServerAPI : public StreamAPI
WiFiClient client;
public:
WiFiServerAPI(WiFiClient &_client);
explicit WiFiServerAPI(WiFiClient &_client);
virtual ~WiFiServerAPI();

Wyświetl plik

@ -156,13 +156,12 @@ ProcessMessage ExternalNotificationPlugin::handleReceived(const MeshPacket &mp)
if (radioConfig.preferences.ext_notification_plugin_enabled) {
auto &p = mp.decoded;
if (getFrom(&mp) != nodeDB.getNodeNum()) {
// TODO: This may be a problem if messages are sent in unicide, but I'm not sure if it will.
// Need to know if and how this could be a problem.
if (radioConfig.preferences.ext_notification_plugin_alert_bell) {
auto &p = mp.decoded;
DEBUG_MSG("externalNotificationPlugin - Notification Bell\n");
for (int i = 0; i < p.payload.size; i++) {
if (p.payload.bytes[i] == ASCII_BELL) {

Wyświetl plik

@ -145,9 +145,9 @@ int32_t PositionPlugin::runOnce()
DEBUG_MSG("Sending pos@%x:6 to mesh (wantReplies=%d)\n", node->position.pos_timestamp, requestReplies);
sendOurPosition(NODENUM_BROADCAST, requestReplies);
} else if (radioConfig.preferences.position_broadcast_smart == true) {
NodeInfo *node = service.refreshMyNodeInfo(); // should guarantee there is now a position
NodeInfo *node2 = service.refreshMyNodeInfo(); // should guarantee there is now a position
if (node->has_position && (node->position.latitude_i != 0 || node->position.longitude_i != 0)) {
if (node2->has_position && (node2->position.latitude_i != 0 || node2->position.longitude_i != 0)) {
// The minimum distance to travel before we are able to send a new position packet.
const uint32_t distanceTravelMinimum = 30;
@ -173,7 +173,7 @@ int32_t PositionPlugin::runOnce()
bool requestReplies = currentGeneration != radioGeneration;
currentGeneration = radioGeneration;
DEBUG_MSG("Sending smart pos@%x:6 to mesh (wantReplies=%d, dt=%d, tt=%d)\n", node->position.pos_timestamp, requestReplies, distanceTravel, timeTravel);
DEBUG_MSG("Sending smart pos@%x:6 to mesh (wantReplies=%d, dt=%d, tt=%d)\n", node2->position.pos_timestamp, requestReplies, distanceTravel, timeTravel);
sendOurPosition(NODENUM_BROADCAST, requestReplies);
/* Update lastGpsSend to now. This means if the device is stationary, then
@ -185,4 +185,4 @@ int32_t PositionPlugin::runOnce()
}
return 5000; // to save power only wake for our callback occasionally
}
}

Wyświetl plik

@ -79,9 +79,9 @@ bool RemoteHardwarePlugin::handleReceivedProtobuf(const MeshPacket &req, Hardwar
HardwareMessage r = HardwareMessage_init_default;
r.typ = HardwareMessage_Type_READ_GPIOS_REPLY;
r.gpio_value = res;
MeshPacket *p = allocDataProtobuf(r);
setReplyTo(p, req);
myReply = p;
MeshPacket *p2 = allocDataProtobuf(r);
setReplyTo(p2, req);
myReply = p2;
break;
}
@ -132,4 +132,4 @@ int32_t RemoteHardwarePlugin::runOnce()
}
return 200; // Poll our GPIOs every 200ms (FIXME, make adjustable via protobuf arg)
}
}

Wyświetl plik

@ -179,7 +179,7 @@ uint32_t StoreForwardPlugin::historyQueueCreate(uint32_t msAgo, uint32_t to)
void StoreForwardPlugin::historyAdd(const MeshPacket &mp)
{
auto &p = mp.decoded;
const auto &p = mp.decoded;
this->packetHistory[this->packetHistoryCurrent].time = millis();
this->packetHistory[this->packetHistoryCurrent].to = mp.to;
@ -247,14 +247,14 @@ ProcessMessage StoreForwardPlugin::handleReceived(const MeshPacket &mp)
DEBUG_MSG("--- S&F Received something\n");
auto &p = mp.decoded;
// The router node should not be sending messages as a client.
if (getFrom(&mp) != nodeDB.getNodeNum()) {
if (mp.decoded.portnum == PortNum_TEXT_MESSAGE_APP) {
DEBUG_MSG("Packet came from - PortNum_TEXT_MESSAGE_APP\n");
auto &p = mp.decoded;
if ((p.payload.bytes[0] == 'S') && (p.payload.bytes[1] == 'F') && (p.payload.bytes[2] == 0x00)) {
DEBUG_MSG("--- --- --- Request to send\n");

Wyświetl plik

@ -50,9 +50,9 @@ class CrossPlatformCryptoEngine : public CryptoEngine
virtual void encrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes) override
{
if (key.length > 0) {
uint8_t stream_block[16];
//uint8_t stream_block[16];
static uint8_t scratch[MAX_BLOCKSIZE];
size_t nc_off = 0;
//size_t nc_off = 0;
// DEBUG_MSG("ESP32 encrypt!\n");
initNonce(fromNode, packetNum);

Wyświetl plik

@ -4,6 +4,14 @@ assertWithSideEffect
// TODO: need to come back to these
duplInheritedMember
// TODO:
// "Using memset() on struct which contains a floating point number."
// tried:
// if (std::is_floating_point<T>::value) {
// p = 0;
// in src/mesh/MemoryPool.h
memsetClassFloat
// no real downside/harm in these
unusedFunction
unusedPrivateFunction