Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PVS-studio code improvement suggestions #1870

Closed
tonhuisman opened this issue Sep 9, 2022 · 6 comments · Fixed by #1875
Closed

PVS-studio code improvement suggestions #1870

tonhuisman opened this issue Sep 9, 2022 · 6 comments · Fixed by #1875
Assignees

Comments

@tonhuisman
Copy link
Contributor

tonhuisman commented Sep 9, 2022

Version: 2.8.2

A recent scan on ESPEasy using PVS-studio revealed a few, most likely low-prio, issues in the IRremoteESP8266 code:

#define _IRREMOTEESP8266_VERSION_VAL(major, minor, patch) \
                                    ((major << 16) | (minor << 8) | (patch))
The macro '_IRREMOTEESP8266_VERSION_VAL' is a dangerous expression. The parameters 'major', 'minor' must be surrounded by parentheses.

As I haven't touched these parts of the sources, I'd like to leave the honor of applying these suggestions (or not) to the core team, as there may be specific reasons for having that coded the way it currently is 😃

Edit: Removed the non-relevant part.

@crankyoldgit crankyoldgit self-assigned this Sep 10, 2022
crankyoldgit added a commit that referenced this issue Sep 10, 2022
Make the parameter expansion safer.
For #1870
@crankyoldgit
Copy link
Owner

crankyoldgit commented Sep 10, 2022

Thanks!

I've created a PR for hopefully fixing the first problem. It's not a significant issue, but fixing it is better than not.

The second one, I'll have a deeper look at. I'm not sure I understand it fully. (i.e. Suggestions welcome ;-)

@tonhuisman
Copy link
Contributor Author

not sure I understand it fully

The original definition in the base class has an uint8_t as the last specified argument, where the overridden method in the derived class has a bool argument there (all other args are the same). PVS-studio is giving a warning that this may be unintentional, a.k.a. a bug, but there can be reasons you might want or need it coded like that. Effectively, the bool is mapped by the compiler to an uint8_t (or maybe a byte or char, idk) as they all seem to be synonyms, so when using the derived method and looking at the signature, this could cause confusion.

NB: PVS-studio is rather picky (sometimes even creepy) in its validation process 😃

@crankyoldgit
Copy link
Owner

Oh thanks. I'll have a look at that with that info in mind. i,e. That was super helpful!

@crankyoldgit
Copy link
Owner

CWE-670:It is possible a virtual function was overridden incorrectly. See eighth argument of function 'send' in derived class 'GreeYAAHeatpumpIR' and base class 'HeatpumpIR'. …GreeHeatpumpIR.h:90:0
(and the same message for line 99)

Embarisingly, It took me far to long to realise it, but that's not our code it's referencing. 😆

i.e. We have no HeatpumpIR, GreeYAAHeatpumpIR, or even a GreeHeatpumpIR.h.

I think your Princess^H^H^H^H^H^H^H^HCWE is in another Castle^H^H^H^H^H^HRepo.

@tonhuisman
Copy link
Contributor Author

😊 Indeed I have confused another lib with this one, probably based on the IR in the filename, apologies.

Case closed.

@crankyoldgit
Copy link
Owner

Leaving this open till the PR is merged.

crankyoldgit added a commit that referenced this issue Sep 10, 2022
Make the parameter expansion safer.
For #1870
crankyoldgit added a commit that referenced this issue Sep 15, 2022
_v2.8.3 (20220915)_

**[Bug Fixes]**
- Fix `#if` for DECODE_COOLIX48 (#1796)
- Add missing `prev`s to `decodeToState()` (#1783)

**[Features]**
- Add `pause()` function to ESP32 when receiving. (#1871)
- ARGO: Argo add `sendSensorTemp()` (#1858 #1859)
- HAIER_AC160: Experimental detail support. (#1852 #1804)
- BOSCH144: Add IRac class support (#1841)
- Mitsubishi_AC: update left vane in `IRac` class (#1837)
- Basic support for Daikin 312bit/39byte A/C protocol. (#1836 #1829)
- Experimental basic support for Sanyo AC 152 bit protocol. (#1828 #1826)
- GREE: Add model support for `YX1FSF`/Soleus Air Windown A/C (#1823 #1821)
- Experimental basic support for Bosch 144bit protocol. (#1822 #1787)
- Experimental basic support for TCL AC 96 bit protocol. (#1820 #1810)
- Add basic support for clima-butler (52bit) RCS-SD43UWI (#1815 #1812)
- TOTO: An experimental _(s)wipe_ at support for Toto Toilets. (#1811 #1806)
- CARRIER_AC128: Experimental Basic support for Carrier AC 128bit protocol. (#1798 #1797)
- HAIER_AC160: Add basic support for Haier 160bit protocol. (#1805 #1804)
- DAIKIN: Add basic support for 200-bit Daikin protocol. (#1803 #1802)
- FUJITSU: Improve handling of 10C Heat mode. (#1788 #1780)
- FUJITSU: Improve handling of short (command only) messages. (#1784 #1780)

**[Misc]**
- Improve the `_IRREMOTEESP8266_VERSION_VAL` macro (#1875 #1870)
- SONY: Update supported devices. (#1872)
- SAMSUNG: Update supported devices (#1873)
- NEC: Update supported devices (#1874)
- Give IRmacros.h smaller scope to avoid impacting projects using IRremoteESP8266 (#1857 #1853 #1851)
- Inhibit protocol names for not-included protocols (#1853 #1851)
- Test out codeql static analysis (#1842)
- Remove pylint disable=no-self-use (#1817)
- Fujitsu General: update supported devices (#1813)
- DAIKIN: Update supported devices (#1808 #1807)
- Fujitsu: Update supported remote info. (#1801 #1794)
- DAIKIN128: Update supported devices (#1754)
- Voltas: Add link to manual for 122LZF A/C. (#1800 #1799 #1238)
- Daikin128: Additional unit test. (#1795 #1754)
- MIDEA: Update supported devices (#1791 #1790)
crankyoldgit added a commit that referenced this issue Sep 16, 2022
**_v2.8.3 (20220915)_**

**[Bug Fixes]**
- Fix `#if` for DECODE_COOLIX48 (#1796)
- Add missing `prev`s to `decodeToState()` (#1783)

**[Features]**
- Add `pause()` function to ESP32 when receiving. (#1871)
- ARGO: Argo add `sendSensorTemp()` (#1858 #1859)
- HAIER_AC160: Experimental detail support. (#1852 #1804)
- BOSCH144: Add IRac class support (#1841)
- Mitsubishi_AC: update left vane in `IRac` class (#1837)
- Basic support for Daikin 312bit/39byte A/C protocol. (#1836 #1829)
- Experimental basic support for Sanyo AC 152 bit protocol. (#1828 #1826)
- GREE: Add model support for `YX1FSF`/Soleus Air Windown A/C (#1823 #1821)
- Experimental basic support for Bosch 144bit protocol. (#1822 #1787)
- Experimental basic support for TCL AC 96 bit protocol. (#1820 #1810)
- Add basic support for clima-butler (52bit) RCS-SD43UWI (#1815 #1812)
- TOTO: An experimental _(s)wipe_ at support for Toto Toilets. (#1811 #1806)
- CARRIER_AC128: Experimental Basic support for Carrier AC 128bit protocol. (#1798 #1797)
- HAIER_AC160: Add basic support for Haier 160bit protocol. (#1805 #1804)
- DAIKIN: Add basic support for 200-bit Daikin protocol. (#1803 #1802)
- FUJITSU: Improve handling of 10C Heat mode. (#1788 #1780)
- FUJITSU: Improve handling of short (command only) messages. (#1784 #1780)

**[Misc]**
- Improve the `_IRREMOTEESP8266_VERSION_VAL` macro (#1875 #1870)
- SONY: Update supported devices. (#1872)
- SAMSUNG: Update supported devices (#1873)
- NEC: Update supported devices (#1874)
- Give IRmacros.h smaller scope to avoid impacting projects using IRremoteESP8266 (#1857 #1853 #1851)
- Inhibit protocol names for not-included protocols (#1853 #1851)
- Test out codeql static analysis (#1842)
- Remove pylint disable=no-self-use (#1817)
- Fujitsu General: update supported devices (#1813)
- DAIKIN: Update supported devices (#1808 #1807)
- Fujitsu: Update supported remote info. (#1801 #1794)
- DAIKIN128: Update supported devices (#1754)
- Voltas: Add link to manual for 122LZF A/C. (#1800 #1799 #1238)
- Daikin128: Additional unit test. (#1795 #1754)
- MIDEA: Update supported devices (#1791 #1790)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants