2016-06-21 01:20 AM
Hello,
while I'm trying to figure out, why a project with USB support is not working as expected, I have to debug a lot in the HAL source code.Nearly all HAL functions have a HAL_StatusTypeDef as return type. I check the result of such functions with an assert(), as I believe that most function will not return an error, if I used the API correctly or if the function does not run out of resources. All that checking is cumbersome and I wish that the called function would have integrated that assert() for API misuse and other SW developer errors. That would leave the return type only for functions that might fail at runtime even when used correctly.But instead I find functions that will return always OK or that will simply ignore return values from called functions. So please:
- If there is a function that can not fail, please use void as return type.
- If a function can fail, please document under which circumstances the function will return which error code.
- If a function can only fail if used not correctly (is called with not given precondition, wrong state, wrong parameters), please do the assert() for us and change the return type to void.
- Please, if a called function returns an error, promote that error to the caller and do not simply swallow it.
I know that we all have to work under resource constrains, but every minute saved on HAL code quality will cost your users (costumers) a multitude of that time.
kind regards,
Torsten
#error-handling #hal #code-qualit2016-06-28 06:47 AM
Hi robitzki.torsten,
Could you please provide examples of functions for which your comments are applicable?It will be easier to understand then report internally for farther checks this way.Thanks for any valuable comment you share.-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2016-07-15 03:22 AM
The continuity of this discussion is [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/response%20to%20HAL%20Code%20Quality&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/AllItems.aspx¤tviews=36]here.
-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.