driver: Fix ana_cmpr negative enum comparison

The C17 standard (sec 6.7.2.2) indicates that the underlying type of an enum is
implementation defined (i.e., can be signed or unsigned). Thus, comparing
"-1 >= some_enum" where "some_enum" is always 0 or largert can return true if
the compiler uses unsigned for enums.

This commit fixes the following issues with ana_cmpr:

- Fixed incorrect comparison in ana_cmpr_del_unit() that relied on enums being
signed, thus would always return true.
- Fixed incorrect expected argument in the "ana_cmpr_unit_install_uninstall"
test. This was not picked up due to the incorrect enum comparison above.
This commit is contained in:
Darian Leung
2023-04-28 14:52:50 +08:00
parent 25222163b9
commit 03ce2fbaf0
2 changed files with 3 additions and 3 deletions
@@ -37,7 +37,7 @@ TEST_CASE("ana_cmpr_unit_install_uninstall", "[ana_cmpr]")
/* Disable the unit */
TEST_ESP_OK(ana_cmpr_disable(cmpr));
/* Try to delete the unit with a wrong handle */
TEST_ESP_ERR(ESP_ERR_INVALID_STATE, ana_cmpr_del_unit((void *)&cmpr));
TEST_ESP_ERR(ESP_ERR_INVALID_ARG, ana_cmpr_del_unit((void *)&cmpr));
/* Delete the unit */
TEST_ESP_OK(ana_cmpr_del_unit(cmpr));