Skip to content

Conversation

etienne-lms
Copy link
Contributor

Add missing test of some HAL functions return value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in this file are no longer accepted AFAIK.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most (all?) of these functions cannot fail so I don't see any value in adding error checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then why do they have a return value. It's weird regarding Zephyr guideline "If a function returns error information, then that error information shall be tested".

That said I'm fine dropping these changes. After seeing a few mixup of HAL return values and standard errno value, I wanted to clean then hence this change series. I expect not functional change with these patches but better HAL integration example for future contributions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe an assertion on return value would be enough.
Alternatively I think at least an inline comment should state that it's safe to discard the return value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then why do they have a return value. It's weird regarding Zephyr guideline "If a function returns error information, then that error information shall be tested".

Something something HAL guidelines. Alas...

Maybe an assertion on return value would be enough. Alternatively I think at least an inline comment should state that it's safe to discard the return value.

__ASSERT_NO_MSG(hal_ret == HAL_OK); checks would be fine by me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, i'll change to assertion.

@etienne-lms etienne-lms force-pushed the stm32-hal-ret-usb branch 2 times, most recently from de57d85 to 46eea7f Compare October 9, 2025 16:34
Add missing test of some HAL functions return value;.

Signed-off-by: Etienne Carriere <[email protected]>
Copy link

sonarqubecloud bot commented Oct 9, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus platform: STM32 ST Micro STM32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants