Fix Cppcheck warnings (#684)

This commit is contained in:
Olivier
2016-12-10 12:46:52 -08:00
committed by Bruce Lacey
parent 8e1ef13804
commit 37881d56ba
6 changed files with 18 additions and 14 deletions
+1 -1
View File
@@ -60,8 +60,8 @@ bool protocolParse(MyMessage &message, char *inputString)
case 5: // Variable value
if (command == C_STREAM) {
blen = 0;
uint8_t val;
while (*str) {
uint8_t val;
val = protocolH2i(*str++) << 4;
val += protocolH2i(*str++);
bvalue[blen] = val;
+4 -2
View File
@@ -426,11 +426,13 @@ bool _processInternalMessages(void)
#if defined(MY_GATEWAY_FEATURE)
// registeration requests are exclusively handled by GW/Controller
#if !defined(MY_REGISTRATION_CONTROLLER)
// auto registration if version compatible
bool approveRegistration = true;
bool approveRegistration;
#if defined(MY_CORE_COMPATIBILITY_CHECK)
approveRegistration = (_msg.getByte() >= MY_CORE_MIN_VERSION);
#else
// auto registration if version compatible
approveRegistration = true;
#endif
#if (F_CPU>16000000)
+2 -5
View File
@@ -256,10 +256,9 @@ void RFM69::send(uint8_t toAddress, const void* buffer, uint8_t bufferSize, bool
bool RFM69::sendWithRetry(uint8_t toAddress, const void* buffer, uint8_t bufferSize,
uint8_t retries, uint8_t retryWaitTime)
{
uint32_t sentTime;
for (uint8_t i = 0; i <= retries; i++) {
send(toAddress, buffer, bufferSize, true);
sentTime = millis();
uint32_t sentTime = millis();
while (millis() - sentTime < retryWaitTime) {
if (ACKReceived(toAddress)) {
//Serial.print(" ~ms:"); Serial.print(millis() - sentTime);
@@ -574,8 +573,6 @@ void SerialPrint_P(PGM_P str, void (*f)(uint8_t) = SerialWrite )
void RFM69::readAllRegs()
{
uint8_t regVal;
#if REGISTER_DETAIL
int capVal;
@@ -590,7 +587,7 @@ void RFM69::readAllRegs()
for (uint8_t regAddr = 1; regAddr <= 0x4F; regAddr++) {
select();
SPI.transfer(regAddr & 0x7F); // send address + r/w bit
regVal = SPI.transfer(0);
uint8_t regVal = SPI.transfer(0);
unselect();
Serial.print(regAddr, HEX);
+5
View File
@@ -111,6 +111,11 @@ public:
_promiscuousMode = false;
_powerLevel = 31;
_isRFM69HW = isRFM69HW;
_address = RF69_BROADCAST_ADDR;
#if defined (SPCR) && defined (SPSR)
_SPCR = 0;
_SPSR = 0;
#endif
}
bool initialize(uint8_t freqBand, uint8_t ID, uint8_t networkID=1); //!< initialize
+5 -5
View File
@@ -156,7 +156,7 @@ LOCAL bool RFM95_initialise(const float frequency)
(void)RFM95_setRadioMode(RFM95_RADIO_MODE_STDBY);
const rfm95_modemConfig_t configuration = { MY_RFM95_MODEM_CONFIGRUATION };
RFM95_setModemRegisters(configuration);
RFM95_setModemRegisters(&configuration);
RFM95_setPreambleLength(RFM95_PREAMBLE_LENGTH);
RFM95_setFrequency(frequency);
// set power level
@@ -331,11 +331,11 @@ LOCAL bool RFM95_setTxPower(uint8_t powerLevel)
}
// Sets registers from a canned modem configuration structure
LOCAL void RFM95_setModemRegisters(const rfm95_modemConfig_t config)
LOCAL void RFM95_setModemRegisters(const rfm95_modemConfig_t* config)
{
RFM95_writeReg(RFM95_REG_1D_MODEM_CONFIG1, config.reg_1d);
RFM95_writeReg(RFM95_REG_1E_MODEM_CONFIG2, config.reg_1e);
RFM95_writeReg(RFM95_REG_26_MODEM_CONFIG3, config.reg_26);
RFM95_writeReg(RFM95_REG_1D_MODEM_CONFIG1, config->reg_1d);
RFM95_writeReg(RFM95_REG_1E_MODEM_CONFIG2, config->reg_1e);
RFM95_writeReg(RFM95_REG_26_MODEM_CONFIG3, config->reg_26);
}
LOCAL void RFM95_setPreambleLength(const uint16_t preambleLength)
+1 -1
View File
@@ -291,7 +291,7 @@ LOCAL uint8_t RFM95_getAddress(void);
* bandwidth, spreading factor etc.
* @param config See modemConfig_t and references therein
*/
LOCAL void RFM95_setModemRegisters(const rfm95_modemConfig_t config);
LOCAL void RFM95_setModemRegisters(const rfm95_modemConfig_t* config);
/**
* @brief Tests whether a new message is available
* @return True if a new, complete, error-free uncollected message is available to be retreived by @ref RFM95_recv()