From 79ec05479db043cf667ec09533e18e366da63b1b Mon Sep 17 00:00:00 2001 From: Kilian Bracher Date: Thu, 27 Jun 2024 16:27:21 +0200 Subject: [PATCH] "encourage" people to check the status return value --- DS2482_HAL.c | 4 ++-- DS2482_HAL.h | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/DS2482_HAL.c b/DS2482_HAL.c index dbad2aa..9dd98c6 100644 --- a/DS2482_HAL.c +++ b/DS2482_HAL.c @@ -252,14 +252,14 @@ static uint8_t crc8; // static bool OWReset() { bool presence; - ds2482_1w_reset(&presence); + (void)ds2482_1w_reset(&presence); return presence; } //-------------------------------------------------------------------------- // Send 8 bits of data to the 1-Wire bus // -static inline void OWWriteByte(uint8_t byte_value) { ds2482_1w_write_byte(byte_value); } +static inline void OWWriteByte(uint8_t byte_value) { (void)ds2482_1w_write_byte(byte_value); } //-------------------------------------------------------------------------- // Send 1 bit of data to teh 1-Wire bus diff --git a/DS2482_HAL.h b/DS2482_HAL.h index 355b3e3..52eaa5a 100644 --- a/DS2482_HAL.h +++ b/DS2482_HAL.h @@ -17,16 +17,20 @@ #define DS2482_TIMEOUT_1W 100 #define DS2482_TIMEOUT_I2C 100 -HAL_StatusTypeDef ds2482_init(I2C_HandleTypeDef* handle); -HAL_StatusTypeDef ds2482_reset(); -HAL_StatusTypeDef ds2482_write_config(uint8_t config); -HAL_StatusTypeDef ds2482_set_read_ptr(uint8_t read_ptr); -HAL_StatusTypeDef ds2482_1w_reset(bool* presence); -HAL_StatusTypeDef ds2482_1w_write_byte(uint8_t byte); -HAL_StatusTypeDef ds2482_1w_read_byte(uint8_t* byte); -HAL_StatusTypeDef ds2482_1w_triplet(uint8_t dir); -HAL_StatusTypeDef ds2482_1w_search(uint16_t max_devices, uint64_t devices[static max_devices]); -HAL_StatusTypeDef ds2482_1w_verify_device(uint64_t device, bool* present); + +#define nag_attr [[nodiscard("Check status for errors!")]] + +nag_attr HAL_StatusTypeDef ds2482_init(I2C_HandleTypeDef* handle); +nag_attr HAL_StatusTypeDef ds2482_reset(); +nag_attr HAL_StatusTypeDef ds2482_write_config(uint8_t config); +nag_attr HAL_StatusTypeDef ds2482_set_read_ptr(uint8_t read_ptr); +nag_attr HAL_StatusTypeDef ds2482_1w_reset(bool* presence); +nag_attr HAL_StatusTypeDef ds2482_1w_write_byte(uint8_t byte); +nag_attr HAL_StatusTypeDef ds2482_1w_read_byte(uint8_t* byte); +nag_attr HAL_StatusTypeDef ds2482_1w_triplet(uint8_t dir); + +nag_attr HAL_StatusTypeDef ds2482_1w_search(uint16_t max_devices, uint64_t devices[static max_devices]); +nag_attr HAL_StatusTypeDef ds2482_1w_verify_device(uint64_t device, bool* present); #endif // DS2482_HAL_H \ No newline at end of file