From 0f11b662a1221bfd328706775796e4495563367b Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sat, 15 Aug 2020 02:04:08 +0300 Subject: [PATCH] compat: c++ alternative to the UNUSED / void-cast macro --- code/espurna/compat.h | 2 -- code/espurna/sensors/ECH1560Sensor.h | 5 +---- code/espurna/sensors/EmonADC121Sensor.h | 3 +-- code/espurna/sensors/EmonADS1X15Sensor.h | 3 +-- code/espurna/sensors/EmonAnalogSensor.h | 3 +-- code/espurna/sensors/EventSensor.h | 2 -- code/espurna/sensors/GeigerSensor.h | 3 +-- 7 files changed, 5 insertions(+), 16 deletions(-) diff --git a/code/espurna/compat.h b/code/espurna/compat.h index 4374cae1..08edf94a 100644 --- a/code/espurna/compat.h +++ b/code/espurna/compat.h @@ -111,5 +111,3 @@ namespace std { #endif -#define UNUSED(x) (void)(x) - diff --git a/code/espurna/sensors/ECH1560Sensor.h b/code/espurna/sensors/ECH1560Sensor.h index d19783ab..0d6378ee 100644 --- a/code/espurna/sensors/ECH1560Sensor.h +++ b/code/espurna/sensors/ECH1560Sensor.h @@ -123,10 +123,7 @@ class ECH1560Sensor : public BaseEmonSensor { return 0; } - void ICACHE_RAM_ATTR handleInterrupt(unsigned char gpio) { - - UNUSED(gpio); - + void ICACHE_RAM_ATTR handleInterrupt(unsigned char) { // if we are trying to find the sync-time (CLK goes high for 1-2ms) if (_dosync == false) { diff --git a/code/espurna/sensors/EmonADC121Sensor.h b/code/espurna/sensors/EmonADC121Sensor.h index c56b33c5..de87b45a 100644 --- a/code/espurna/sensors/EmonADC121Sensor.h +++ b/code/espurna/sensors/EmonADC121Sensor.h @@ -143,8 +143,7 @@ class EmonADC121Sensor : public EmonSensor { i2c_write_uint8(_address, ADC121_REG_CONFIG, 0); } - unsigned int readADC(unsigned char channel) { - UNUSED(channel); + unsigned int readADC(unsigned char) { unsigned int value = i2c_read_uint16(_address, ADC121_REG_RESULT) & 0x0FFF; return value; } diff --git a/code/espurna/sensors/EmonADS1X15Sensor.h b/code/espurna/sensors/EmonADS1X15Sensor.h index 59b83e63..fd432b6c 100644 --- a/code/espurna/sensors/EmonADS1X15Sensor.h +++ b/code/espurna/sensors/EmonADS1X15Sensor.h @@ -336,8 +336,7 @@ class EmonADS1X15Sensor : public EmonSensor { } - unsigned int readADC(unsigned char channel) { - UNUSED(channel); + unsigned int readADC(unsigned char) { unsigned int value = i2c_read_uint16(_address, ADS1X15_REG_POINTER_CONVERT); if (_type == ADS1X15_CHIP_ADS1015) value >>= ADS1015_BIT_SHIFT; delayMicroseconds(500); diff --git a/code/espurna/sensors/EmonAnalogSensor.h b/code/espurna/sensors/EmonAnalogSensor.h index bcdde0bd..c873dba0 100644 --- a/code/espurna/sensors/EmonAnalogSensor.h +++ b/code/espurna/sensors/EmonAnalogSensor.h @@ -117,8 +117,7 @@ class EmonAnalogSensor : public EmonSensor { protected: - unsigned int readADC(unsigned char channel) { - UNUSED(channel); + unsigned int readADC(unsigned char) { return analogRead(0); } diff --git a/code/espurna/sensors/EventSensor.h b/code/espurna/sensors/EventSensor.h index 53dc2461..6cabdeb5 100644 --- a/code/espurna/sensors/EventSensor.h +++ b/code/espurna/sensors/EventSensor.h @@ -138,8 +138,6 @@ class EventSensor : public BaseSensor { // Handle interrupt calls from isr[GPIO] functions void ICACHE_RAM_ATTR handleInterrupt(unsigned char gpio) { - UNUSED(gpio); - // clock count in 32bit value, overflowing: // ~53s when F_CPU is 80MHz // ~26s when F_CPU is 160MHz diff --git a/code/espurna/sensors/GeigerSensor.h b/code/espurna/sensors/GeigerSensor.h index 7ed39d0d..cf288586 100644 --- a/code/espurna/sensors/GeigerSensor.h +++ b/code/espurna/sensors/GeigerSensor.h @@ -169,8 +169,7 @@ double value(unsigned char index) { // Handle interrupt calls -void handleInterrupt(unsigned char gpio) { - UNUSED(gpio); +void handleInterrupt(unsigned char) { static unsigned long last = 0; if (millis() - last > _debounce) { _events = _events + 1;