Skip to content

video: addition of __ASSERT to ensure proper arguments in api functions #90415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 28, 2025

Conversation

avolmat-st
Copy link
Collaborator

Over the video api function, some functions perform some pointer validation, via if statements or via __ASSERT while some other don't.
Some drivers also performs some pointers validity check (mostly on fmt pointers) while other don't.

In order to try to have something similar for all and avoid drivers having to think about wherher pointer checking is necessary or not, perform those checks within all API functions. Within api ops, drivers can now consider that all pointers are valid.

josuah
josuah previously approved these changes May 23, 2025
ngphibang
ngphibang previously approved these changes May 24, 2025
Copy link
Collaborator

@ngphibang ngphibang left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks !

BTW, I am not sure between __ASSERT and return -EINVAL, which one is more appropriate ? Returning error codes can let the program continue but require the caller to check the return value, ASSERT is simpler (I am up for ASSERT) ...

@avolmat-st
Copy link
Collaborator Author

LGTM. Thanks !

BTW, I am not sure between __ASSERT and return -EINVAL, which one is more appropriate ? Returning error codes can let the program continue but require the caller to check the return value, ASSERT is simpler (I am up for ASSERT) ...

I am been wondering myself as well. Here I think all parameters checked with ASSERT are never expected to have such value, meaning that there is for sure an issue in the application or caller, thus it seemed to be that anyway it doesn't make sense to let the program proceed, hence using ASSERT.

@josuah josuah assigned josuah and unassigned mmahadevan108 and dleach02 May 24, 2025
@josuah
Copy link
Collaborator

josuah commented May 24, 2025

switching the automated assignee to a video collaborator to reduce notification spam

marekmatej
marekmatej previously approved these changes May 24, 2025
wmrsouza
wmrsouza previously approved these changes May 24, 2025
@avolmat-st avolmat-st dismissed stale reviews from wmrsouza, marekmatej, ngphibang, and josuah via 0ce0683 May 26, 2025 20:00
@avolmat-st
Copy link
Collaborator Author

Updates following @pdgendt comments

josuah
josuah previously approved these changes May 26, 2025
Copy link
Collaborator

@josuah josuah left a comment

Choose a reason for hiding this comment

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

Thank you for the modification!

pdgendt
pdgendt previously approved these changes May 27, 2025
wmrsouza
wmrsouza previously approved these changes May 27, 2025
Alain Volmat added 4 commits May 27, 2025 15:33
Protect video API functions via __ASSERT_NO_MSG call to ensure that
required pointers are valid when entering functions.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Now that video api functions have __ASSERT_NO_MSG calls, drivers
do not need to check the entry point functions pointers.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Add checks regarding specific values (numerator / denominator) not being
0 for frame intervals.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Now that api core functions check that denominator / numerator are not
null, it is no more necessary to perform this check within drivers.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
@avolmat-st avolmat-st dismissed stale reviews from wmrsouza and pdgendt via 8726860 May 27, 2025 13:37
Copy link

@josuah josuah requested a review from pdgendt May 27, 2025 22:02
@kartben kartben merged commit 087a08c into zephyrproject-rtos:main May 28, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Video Video subsystem platform: ESP32 Espressif ESP32 platform: NXP Drivers NXP Semiconductors, drivers platform: STM32 ST Micro STM32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants