From 89e406775dbfa91d29747edaaeec1ea86656a573 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 11 May 2024 20:33:07 +0100 Subject: [PATCH] [Pager] Fixed issues found by cppcheck --- src/protocols/Pager/Pager.cpp | 9 ++------- src/protocols/Pager/Pager.h | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/protocols/Pager/Pager.cpp b/src/protocols/Pager/Pager.cpp index 48edee62..e9aa14a4 100644 --- a/src/protocols/Pager/Pager.cpp +++ b/src/protocols/Pager/Pager.cpp @@ -28,9 +28,6 @@ PagerClient::PagerClient(PhysicalLayer* phy) { #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE readBitInstance = phyLayer; #endif - filterNumAddresses = 0; - filterAddresses = NULL; - filterMasks = NULL; } int16_t PagerClient::begin(float base, uint16_t speed, bool invert, uint16_t shift) { @@ -206,7 +203,7 @@ int16_t PagerClient::transmit(uint8_t* data, size_t len, uint32_t addr, uint8_t // in BCD mode, pad the rest of the code word with spaces (0xC) if(encoding == RADIOLIB_PAGER_BCD) { uint8_t numSteps = (symbolPos - RADIOLIB_PAGER_FUNC_BITS_POS + symbolLength)/symbolLength; - for(uint8_t i = 0; i < numSteps; i++) { + for(uint8_t j = 0; j < numSteps; j++) { symbol = encodeBCD(' '); symbol = Module::reflect(symbol, 8); symbol >>= (8 - symbolLength); @@ -397,17 +394,15 @@ int16_t PagerClient::readData(uint8_t* data, size_t* len, uint32_t* addr) { } // we have the address, start pulling out the message - bool complete = false; size_t decodedBytes = 0; uint32_t prevCw = 0; bool overflow = false; int8_t ovfBits = 0; - while(!complete && phyLayer->available()) { + while(phyLayer->available()) { uint32_t cw = read(); // check if it's the idle code word if(cw == RADIOLIB_PAGER_IDLE_CODE_WORD) { - complete = true; break; } diff --git a/src/protocols/Pager/Pager.h b/src/protocols/Pager/Pager.h index 1663ae03..6963a686 100644 --- a/src/protocols/Pager/Pager.h +++ b/src/protocols/Pager/Pager.h @@ -177,17 +177,17 @@ class PagerClient { #endif PhysicalLayer* phyLayer; - float baseFreq; - float dataRate; - uint32_t baseFreqRaw; - uint16_t shiftFreq; - uint16_t shiftFreqHz; - RadioLibTime_t bitDuration; - uint32_t filterAddr; - uint32_t filterMask; - uint32_t *filterAddresses; - uint32_t *filterMasks; - size_t filterNumAddresses; + float baseFreq = 0; + float dataRate = 0; + uint32_t baseFreqRaw = 0; + uint16_t shiftFreq = 0; + uint16_t shiftFreqHz = 0; + RadioLibTime_t bitDuration = 0; + uint32_t filterAddr = 0; + uint32_t filterMask = 0; + uint32_t *filterAddresses = nullptr; + uint32_t *filterMasks = nullptr; + size_t filterNumAddresses = 0; bool inv = false; void write(uint32_t* data, size_t len);