fix a lot of nuisances reported by cppcheck (#4872)

* fix a lot of nuisances reported by cppcheck

* fix portduino
This commit is contained in:
Thomas Göttgens
2024-09-26 02:09:06 +02:00
committed by GitHub
parent 118809fbfc
commit 12481b568a
18 changed files with 33 additions and 35 deletions

View File

@@ -1026,7 +1026,7 @@ bool AdminModule::checkPassKey(meshtastic_AdminMessage *res)
memcmp(res->session_passkey.bytes, session_passkey, 8) == 0);
}
bool AdminModule::messageIsResponse(meshtastic_AdminMessage *r)
bool AdminModule::messageIsResponse(const meshtastic_AdminMessage *r)
{
if (r->which_payload_variant == meshtastic_AdminMessage_get_channel_response_tag ||
r->which_payload_variant == meshtastic_AdminMessage_get_owner_response_tag ||
@@ -1043,7 +1043,7 @@ bool AdminModule::messageIsResponse(meshtastic_AdminMessage *r)
return false;
}
bool AdminModule::messageIsRequest(meshtastic_AdminMessage *r)
bool AdminModule::messageIsRequest(const meshtastic_AdminMessage *r)
{
if (r->which_payload_variant == meshtastic_AdminMessage_get_channel_request_tag ||
r->which_payload_variant == meshtastic_AdminMessage_get_owner_request_tag ||

View File

@@ -55,8 +55,8 @@ class AdminModule : public ProtobufModule<meshtastic_AdminMessage>, public Obser
void setPassKey(meshtastic_AdminMessage *res);
bool checkPassKey(meshtastic_AdminMessage *res);
bool messageIsResponse(meshtastic_AdminMessage *r);
bool messageIsRequest(meshtastic_AdminMessage *r);
bool messageIsResponse(const meshtastic_AdminMessage *r);
bool messageIsRequest(const meshtastic_AdminMessage *r);
};
extern AdminModule *adminModule;

View File

@@ -78,16 +78,16 @@ int CannedMessageModule::splitConfiguredMessages()
int messageIndex = 0;
int i = 0;
String messages = cannedMessageModuleConfig.messages;
String canned_messages = cannedMessageModuleConfig.messages;
#if defined(T_WATCH_S3) || defined(RAK14014)
String separator = messages.length() ? "|" : "";
String separator = canned_messages.length() ? "|" : "";
messages = "[---- Free Text ----]" + separator + messages;
canned_messages = "[---- Free Text ----]" + separator + canned_messages;
#endif
// collect all the message parts
strncpy(this->messageStore, messages.c_str(), sizeof(this->messageStore));
strncpy(this->messageStore, canned_messages.c_str(), sizeof(this->messageStore));
// The first message points to the beginning of the store.
this->messages[messageIndex++] = this->messageStore;

View File

@@ -216,7 +216,7 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt
uint32_t agoSecs = GetTimeSinceMeshPacket(lastMeasurementPacket);
const char *lastSender = getSenderShortName(*lastMeasurementPacket);
auto &p = lastMeasurementPacket->decoded;
const meshtastic_Data &p = lastMeasurementPacket->decoded;
if (!pb_decode_from_bytes(p.payload.bytes, p.payload.size, &meshtastic_Telemetry_msg, &lastMeasurement)) {
display->drawString(x, y, "Measurement Error");
LOG_ERROR("Unable to decode last packet");

View File

@@ -122,7 +122,7 @@ void PowerTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *s
uint32_t agoSecs = GetTimeyWimeySinceMeshPacket(lastMeasurementPacket);
const char *lastSender = getSenderShortName(*lastMeasurementPacket);
auto &p = lastMeasurementPacket->decoded;
const meshtastic_Data &p = lastMeasurementPacket->decoded;
if (!pb_decode_from_bytes(p.payload.bytes, p.payload.size, &meshtastic_Telemetry_msg, &lastMeasurement)) {
display->setFont(FONT_SMALL);
display->drawString(x, y += _fontHeight(FONT_MEDIUM), "Measurement Error");

View File

@@ -11,7 +11,7 @@ bool TraceRouteModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, m
void TraceRouteModule::alterReceivedProtobuf(meshtastic_MeshPacket &p, meshtastic_RouteDiscovery *r)
{
auto &incoming = p.decoded;
const meshtastic_Data &incoming = p.decoded;
// Insert unknown hops if necessary
insertUnknownHops(p, r, !incoming.request_id);

View File

@@ -89,7 +89,7 @@ void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state,
display->fillRect(0 + x, 0 + y, x + display->getWidth(), y + FONT_HEIGHT_SMALL);
// Decode the waypoint
meshtastic_MeshPacket &mp = devicestate.rx_waypoint;
const meshtastic_MeshPacket &mp = devicestate.rx_waypoint;
meshtastic_Waypoint wp;
memset(&wp, 0, sizeof(wp));
if (!pb_decode_from_bytes(mp.decoded.payload.bytes, mp.decoded.payload.size, &meshtastic_Waypoint_msg, &wp)) {