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: avdtp: avoid that the ret and err exist together #87056

Conversation

MarkWangChinese
Copy link
Contributor

Keep the err in code as it is convention in Bluetooth code, change ret as l2cap_ret because it is the return value of l2cap send function.

Copy link
Member

@jhedberg jhedberg left a comment

Choose a reason for hiding this comment

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

Good initiative! However, I'd propose to do it slightly differently (and simpler).

Comment on lines 428 to 431
int ret;
int l2cap_ret;
struct bt_avdtp_sep *sep;
struct net_buf *rsp_buf;
uint8_t error_code = 0;
Copy link
Member

Choose a reason for hiding this comment

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

It's actually worse, since you have three error variables here with error_code included. I think you should be able to remove l2cap_ret completely and just reuse err when you need to store the value from l2cap_chan_send(). I'd also rename error_code to avdtp_err. At the end of the function when you need to decide about the state change, you shouldn't need to look at err at all, rather !reconfig && avdtp_err == 0 is all that you need.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove l2cap_ret. Change error_code as avdtp_err_code, keep code in the variable because the avdtp spec say it as ERROR_CODE.

Keep the err in code as it is convention in Bluetooth code, remove ret,
change error_code as avdtp_err_code for avdtp protocol error.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
@MarkWangChinese MarkWangChinese force-pushed the feature/avdtp_optimze_for_more_readable branch from c703237 to 3bb68b0 Compare March 14, 2025 02:47
@kartben kartben merged commit e5742b2 into zephyrproject-rtos:main Mar 21, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants