-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Bluetooth: TMAP: Add role validation for bt_tmap_register #81279
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
Conversation
subsys/bluetooth/audio/tmap.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| LOG_DBG("Device does not support the CY role"); | |
| LOG_DBG("Device does not support the CT role"); |
subsys/bluetooth/audio/tmap.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not specific for this PR, but also shows up other places where CHECKIF is used, and will be compiler dependent:
If the KCONFIG option NO_RUNTIME_CHECKS is set to 'y' a compiler may emit the following warning: static bool valid_tmap_role defined but not used
suggestions for fixing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two ways we can apply is to guard this call with an IS_ENABLED, or instead of having CHECKIF in the call, we can change all the checks in the functions to use CHECKIF to that if NO_RUNTIME_CHECKS then the function is just a no-op.
But you have a good point that we should do that here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the macro it is defined as
#elif defined(CONFIG_NO_RUNTIME_CHECKS)
#define CHECKIF(...) \
if (0)
#elseWith if (0) the code is still compiled, but not linked, and should thus not have any issues. Will leave as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the code compiles and works fine as is, the only issue is that we get a compiler warning, that shouldn't be there.
6fae72e to
00a772a
Compare
f8c3f61 to
149a400
Compare
subsys/bluetooth/audio/Kconfig.tmap
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice to wrap this very long line?
subsys/bluetooth/audio/Kconfig.tmap
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Add validation that the device supports the role set by bt_tmap_register. Signed-off-by: Emil Gydesen <[email protected]>
149a400 to
fccfa75
Compare
Add validation that the device supports the role
set by bt_tmap_register.
fixes #60495