Skip to content
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

Bluetooth: Audio: Fix bad docs for codec helper functions #81799

Merged
merged 1 commit into from
Nov 28, 2024

Conversation

Thalley
Copy link
Collaborator

@Thalley Thalley commented Nov 22, 2024

Several of the codec helper functions used @RetVal incorrectly Several functions referenced @ccid_list incorrectly

@Thalley Thalley self-assigned this Nov 22, 2024
@@ -845,9 +845,9 @@ int bt_audio_codec_cfg_freq_hz_to_freq(uint32_t freq_hz);
* @param codec_cfg The codec configuration to extract data from.
*
* @retval A @ref bt_audio_codec_cfg_freq value
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missed this one

@@ -890,9 +890,9 @@ int bt_audio_codec_cfg_frame_dur_us_to_frame_dur(uint32_t frame_dur_us);
* @param codec_cfg The codec configuration to extract data from.
*
* @retval A @ref bt_audio_codec_cfg_frame_dur value
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto

* @retval -EINVAL if arguments are invalid.
* @retval The converted frequency value in Hz.
* @retval -EINVAL Arguments are invalid.
* @retval frequency The converted frequency value in Hz.
Copy link
Collaborator

@kartben kartben Nov 23, 2024

Choose a reason for hiding this comment

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

You want this one listed first I think, i.e. the most likely return value first (applies throughout the PR)

Related, and since we don't have guidelines just yet and I very much value your thoughts on this topic and the fact we can use this PR as a way to settle on best practices for documenting return values, how about the "non-distinctive" value be described using @return? Basically, this: https://docs.rtems.org/branches/master/eng/coding-doxygen.html#function-declarations

Copy link
Collaborator

Choose a reason for hiding this comment

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

So I take it you're not in favor of using @return then? Or maybe there was too much info in my comment and you missed that part :)

Suggested change
* @retval frequency The converted frequency value in Hz.
* @return The converted frequency value in Hz.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

how about the "non-distinctive" value be described using @return

So this is suggesting to use @retval for specific values, and @return for values that may range?

So in this example this would be something like

 * @retval -EINVAL Arguments are invalid.
 * 
 * @return The converted frequency value in Hz.

I'm not opposed to it, depending on how it would render in the built docs :) It does make sense to only use @retval for specific values. Speaking of, should we use - @ref EINVAL? or add something like a @errno{EINVAL}?

I think it makes sense to propose an RFC to discuss this

Copy link
Collaborator

Choose a reason for hiding this comment

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

Speaking of, should we use - @ref EINVAL? or add something like a @errno{EINVAL}?

Good question. Given that retval accepts ONE token representing the return value, the former likely won't work, and not sure about the latter either. That being said, I like the idea as making it easier to navigate to the list of available errnos can only be goodness.

+1 to address the next iteration (combining usage of @return and @retval) in a follow-up RFC

kartben
kartben previously approved these changes Nov 25, 2024
* @retval -EINVAL if arguments are invalid.
* @retval The converted frequency value in Hz.
* @retval -EINVAL Arguments are invalid.
* @retval frequency The converted frequency value in Hz.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Speaking of, should we use - @ref EINVAL? or add something like a @errno{EINVAL}?

Good question. Given that retval accepts ONE token representing the return value, the former likely won't work, and not sure about the latter either. That being said, I like the idea as making it easier to navigate to the list of available errnos can only be goodness.

+1 to address the next iteration (combining usage of @return and @retval) in a follow-up RFC

Copy link
Collaborator

@kruithofa kruithofa left a comment

Choose a reason for hiding this comment

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

LGTM, just some nitpicks

@@ -869,8 +869,8 @@ int bt_audio_codec_cfg_set_freq(struct bt_audio_codec_cfg *codec_cfg,
*
* @param frame_dur The assigned numbers frame duration to convert.
*
* @retval -EINVAL if arguments are invalid.
* @retval The converted frame duration value in microseconds.
* @retval duraction The converted frame duration value in microseconds.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* @retval duraction The converted frame duration value in microseconds.
* @retval duration The converted frame duration value in microseconds.

* @retval -ENOMEM if the new value could not set or added due to memory
* @retval data_len The data_len of @p codec_cfg on success
* @retval -EINVAL Arguments are invalid
* @retval -ENOMEM The new value could not set or added due to memory
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* @retval -ENOMEM The new value could not set or added due to memory
* @retval -ENOMEM The new value could not be set or added due to lack of memory

Same text change for the other places where -ENOMEM is returned

@@ -777,8 +777,8 @@ int bt_audio_data_parse(const uint8_t ltv[], size_t size,
* Any found data will be little endian.
*
* @retval Length The length of found @p data (may be 0).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe not part of this PR, but using a lowercase l is consistent with the parameter description in the other
fucntions

Suggested change
* @retval Length The length of found @p data (may be 0).
* @retval length The length of found @p data (may be 0).

* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
* @retval data_len The data_len of @p codec_cfg on success
Copy link
Collaborator

Choose a reason for hiding this comment

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

In some other functions where the return value is len the description says length of ..., maybe the same should be done for data_len and meta_len, here and in other functions

Suggested change
* @retval data_len The data_len of @p codec_cfg on success
* @retval data_len The data length of @p codec_cfg on success

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, I get your point. data_len length here refer to the data_len field of codec_cfg. Will rewrite a bit

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1, this too caught my eye fwiw :)

kruithofa
kruithofa previously approved these changes Nov 27, 2024
Copy link
Collaborator

@kruithofa kruithofa left a comment

Choose a reason for hiding this comment

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

One nitpick, but nothing blocking

* @retval The meta_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
* @retval meta_len The meta_len of @p codec_cfg on success
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shall we do the same as for the data_len field of codec_cfg?

Suggested change
* @retval meta_len The meta_len of @p codec_cfg on success
* @retval meta_len The @p codec_cfg.meta_len on success

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, will update

@@ -1099,8 +1099,8 @@ int bt_audio_codec_cfg_meta_set_val(struct bt_audio_codec_cfg *codec_cfg,
* @param codec_cfg The codec data to set the value in.
* @param type The type id to unset.
*
* @retval The meta_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval meta_len The meta_len of @p codec_cfg on success
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* @retval meta_len The meta_len of @p codec_cfg on success
* @retval meta_len The @p codec_cfg.meta_len on success

Several of the codec helper functions used @RetVal incorrectly
Several functions referenced @ccid_list incorrectly

Signed-off-by: Emil Gydesen <[email protected]>
@Thalley Thalley requested a review from kruithofa November 27, 2024 18:26
@kartben kartben merged commit f254280 into zephyrproject-rtos:main Nov 28, 2024
24 checks passed
@Thalley Thalley deleted the codec_doc_fixes branch November 28, 2024 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants