From ed4c18f2be38e275b3a87865b7495ea442164436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 29 Nov 2020 19:02:52 +0100 Subject: [PATCH] Add error checking function for config parser --- stm-firmware/config-parser/config-parser.c | 11 +++++++++++ .../include/config-parser/config-parser.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/stm-firmware/config-parser/config-parser.c b/stm-firmware/config-parser/config-parser.c index d372ef5..42635a4 100644 --- a/stm-firmware/config-parser/config-parser.c +++ b/stm-firmware/config-parser/config-parser.c @@ -188,4 +188,15 @@ enum config_parser_ret config_parser_close_file(config_parser_handle_t handle) return (res == FR_OK ? CONFIG_PARSER_OK : CONFIG_PARSER_IOERR); } +bool config_parser_ret_is_abort_condition(enum config_parser_ret return_val) +{ + if (return_val == CONFIG_PARSER_END_REACHED || + return_val == CONFIG_PARSER_GENERIC_ERR || + return_val == CONFIG_PARSER_IOERR || + return_val == CONFIG_PARSER_PARAM_ERR) + return true; + + return false; +} + /** @} */ diff --git a/stm-firmware/config-parser/include/config-parser/config-parser.h b/stm-firmware/config-parser/include/config-parser/config-parser.h index df9181b..50767ca 100644 --- a/stm-firmware/config-parser/include/config-parser/config-parser.h +++ b/stm-firmware/config-parser/include/config-parser/config-parser.h @@ -90,6 +90,8 @@ enum config_parser_ret config_parser_write_entry(config_parser_handle_t handle, enum config_parser_ret config_parser_close_file(config_parser_handle_t handle); +bool config_parser_ret_is_abort_condition(enum config_parser_ret return_val); + #endif /* _CONFIG_PARSER_H_ */ /** @} */