From 96348de1459c22c874dd82d01fdf05add71d5c3e Mon Sep 17 00:00:00 2001 From: karamo Date: Thu, 13 Jan 2022 22:18:18 +0100 Subject: [PATCH 1/3] minor changes warning: comparison is always true due to limited range of data type and add parentheses --- RNode_Firmware.ino | 10 +++++----- Utilities.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index 6c03019..8d0386b 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -422,7 +422,7 @@ void serialCallback(uint8_t sbyte) { if (!fifo16_isfull(&packet_starts) && queued_bytes < CONFIG_QUEUE_SIZE) { uint16_t s = current_packet_start; - uint16_t e = queue_cursor-1; if (e == -1) e = CONFIG_QUEUE_SIZE-1; + int e = queue_cursor-1; if (e == -1) e = CONFIG_QUEUE_SIZE-1; uint16_t l; if (s != e) { @@ -631,9 +631,9 @@ void serialCallback(uint8_t sbyte) { void updateModemStatus() { uint8_t status = LoRa.modemStatus(); last_status_update = millis(); - if (status & SIG_DETECT == SIG_DETECT) { stat_signal_detected = true; } else { stat_signal_detected = false; } - if (status & SIG_SYNCED == SIG_SYNCED) { stat_signal_synced = true; } else { stat_signal_synced = false; } - if (status & RX_ONGOING == RX_ONGOING) { stat_rx_ongoing = true; } else { stat_rx_ongoing = false; } + if (status & (SIG_DETECT == SIG_DETECT)) { stat_signal_detected = true; } else { stat_signal_detected = false; } + if (status & (SIG_SYNCED == SIG_SYNCED)) { stat_signal_synced = true; } else { stat_signal_synced = false; } + if (status & (RX_ONGOING == RX_ONGOING)) { stat_rx_ongoing = true; } else { stat_rx_ongoing = false; } if (stat_signal_detected || stat_signal_synced || stat_rx_ongoing) { if (dcd_count < dcd_threshold) { @@ -849,4 +849,4 @@ void serial_interrupt_init() { ISR(TIMER3_CAPT_vect) { buffer_serial(); } -#endif \ No newline at end of file +#endif diff --git a/Utilities.h b/Utilities.h index fa45296..5be1ccf 100644 --- a/Utilities.h +++ b/Utilities.h @@ -512,9 +512,9 @@ void eeprom_update(int mapped_addr, uint8_t byte) { } -void eeprom_write(uint8_t addr, uint8_t byte) { - if (!eeprom_info_locked() && addr >= 0 && addr < EEPROM_RESERVED) { - eeprom_update(eeprom_addr(addr), byte); +void eeprom_write(int addr, uint8_t vbyte) { + if (!eeprom_info_locked() && (addr >= 0) && (addr < EEPROM_RESERVED)) { + eeprom_update(eeprom_addr(addr), vbyte); } else { kiss_indicate_error(ERROR_EEPROM_LOCKED); } From 72a4678949f88de378a436858be9ab99690a20c1 Mon Sep 17 00:00:00 2001 From: karamo Date: Fri, 14 Jan 2022 01:04:28 +0100 Subject: [PATCH 2/3] Update RNode_Firmware.ino correct parentheses --- RNode_Firmware.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index 8d0386b..fda5a46 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -631,9 +631,9 @@ void serialCallback(uint8_t sbyte) { void updateModemStatus() { uint8_t status = LoRa.modemStatus(); last_status_update = millis(); - if (status & (SIG_DETECT == SIG_DETECT)) { stat_signal_detected = true; } else { stat_signal_detected = false; } - if (status & (SIG_SYNCED == SIG_SYNCED)) { stat_signal_synced = true; } else { stat_signal_synced = false; } - if (status & (RX_ONGOING == RX_ONGOING)) { stat_rx_ongoing = true; } else { stat_rx_ongoing = false; } + if ((status & SIG_DETECT) == SIG_DETECT) { stat_signal_detected = true; } else { stat_signal_detected = false; } + if ((status & SIG_SYNCED) == SIG_SYNCED) { stat_signal_synced = true; } else { stat_signal_synced = false; } + if ((status & RX_ONGOING) == RX_ONGOING) { stat_rx_ongoing = true; } else { stat_rx_ongoing = false; } if (stat_signal_detected || stat_signal_synced || stat_rx_ongoing) { if (dcd_count < dcd_threshold) { From 291868af6db5ae33f5966cf71c8dfa01e6b124d4 Mon Sep 17 00:00:00 2001 From: karamo Date: Fri, 14 Jan 2022 09:37:38 +0100 Subject: [PATCH 3/3] remove warnings "unused variable" "uninitialized" --- RNode_Firmware.ino | 6 +++--- Utilities.h | 36 ++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index fda5a46..8921fd9 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -363,7 +363,7 @@ void transmit(uint16_t size) { LoRa.beginPacket(); LoRa.write(header); written++; - for (uint16_t i; i < size; i++) { + for (int i=0; i < size; i++) { LoRa.write(tbuf[i]); written++; @@ -400,7 +400,7 @@ void transmit(uint16_t size) { LoRa.beginPacket(size); } - for (uint16_t i; i < size; i++) { + for (int i=0; i < size; i++) { LoRa.write(tbuf[i]); written++; @@ -805,7 +805,7 @@ void buffer_serial() { // Discard GPS data for now c = 0; while (c < MAX_CYCLES && Serial1.available()) { - uint8_t void_c = Serial1.read(); + Serial1.read(); } #endif diff --git a/Utilities.h b/Utilities.h index 5be1ccf..8589491 100644 --- a/Utilities.h +++ b/Utilities.h @@ -210,10 +210,10 @@ int8_t led_standby_direction = 0; } #endif -void escapedSerialWrite(uint8_t byte) { - if (byte == FEND) { Serial.write(FESC); byte = TFEND; } - if (byte == FESC) { Serial.write(FESC); byte = TFESC; } - Serial.write(byte); +void escapedSerialWrite(uint8_t vbyte) { + if (vbyte == FEND) { Serial.write(FESC); vbyte = TFEND; } + if (vbyte == FESC) { Serial.write(FESC); vbyte = TFESC; } + Serial.write(vbyte); } void kiss_indicate_reset() { @@ -327,10 +327,10 @@ void kiss_indicate_frequency() { Serial.write(FEND); } -void kiss_indicate_random(uint8_t byte) { +void kiss_indicate_random(uint8_t vbyte) { Serial.write(FEND); Serial.write(CMD_RANDOM); - Serial.write(byte); + Serial.write(vbyte); Serial.write(FEND); } @@ -474,22 +474,22 @@ bool eeprom_info_locked() { void eeprom_dump_info() { for (int addr = ADDR_PRODUCT; addr <= ADDR_INFO_LOCK; addr++) { - uint8_t byte = EEPROM.read(eeprom_addr(addr)); - escapedSerialWrite(byte); + uint8_t vbyte = EEPROM.read(eeprom_addr(addr)); + escapedSerialWrite(vbyte); } } void eeprom_dump_config() { for (int addr = ADDR_CONF_SF; addr <= ADDR_CONF_OK; addr++) { - uint8_t byte = EEPROM.read(eeprom_addr(addr)); - escapedSerialWrite(byte); + uint8_t vbyte = EEPROM.read(eeprom_addr(addr)); + escapedSerialWrite(vbyte); } } void eeprom_dump_all() { for (int addr = 0; addr < EEPROM_RESERVED; addr++) { - uint8_t byte = EEPROM.read(eeprom_addr(addr)); - escapedSerialWrite(byte); + uint8_t vbyte = EEPROM.read(eeprom_addr(addr)); + escapedSerialWrite(vbyte); } } @@ -500,12 +500,12 @@ void kiss_dump_eeprom() { Serial.write(FEND); } -void eeprom_update(int mapped_addr, uint8_t byte) { +void eeprom_update(int mapped_addr, uint8_t vbyte) { #if MCU_VARIANT == MCU_1284P || MCU_VARIANT == MCU_2560 - EEPROM.update(mapped_addr, byte); + EEPROM.update(mapped_addr, vbyte); #elif MCU_VARIANT == MCU_ESP32 - if (EEPROM.read(mapped_addr) != byte) { - EEPROM.write(mapped_addr, byte); + if (EEPROM.read(mapped_addr) != vbyte) { + EEPROM.write(mapped_addr, vbyte); EEPROM.commit(); } #endif @@ -565,8 +565,8 @@ bool eeprom_hwrev_valid() { bool eeprom_checksum_valid() { char *data = (char*)malloc(CHECKSUMMED_SIZE); for (uint8_t i = 0; i < CHECKSUMMED_SIZE; i++) { - char byte = EEPROM.read(eeprom_addr(i)); - data[i] = byte; + char vbyte = EEPROM.read(eeprom_addr(i)); + data[i] = vbyte; } unsigned char *hash = MD5::make_hash(data, CHECKSUMMED_SIZE);