-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
usb: device: fix unaligned memory access in Audio class #79491
usb: device: fix unaligned memory access in Audio class #79491
Conversation
@@ -53,7 +53,7 @@ static void feature_update(const struct device *dev, | |||
case USB_AUDIO_FU_MUTE_CONTROL: | |||
break; | |||
case USB_AUDIO_FU_VOLUME_CONTROL: | |||
volume = *((int16_t *)(evt->val)); | |||
volume = UNALIGNED_GET((int16_t *)evt->val); |
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 it work with clang and why not just memcpy(&volume, evt->val, sizeof(volume));
?
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.
My development environment is not convenient for testing clang (soc is a customized mips), but zephyr also uses UNALIGNED_GET in many places, and include/zephyr/toolchain/llvm.h
includes include/zephyr/toolchain/gcc.h
, so clang should also be able to use it. If you have any doubts about this, I can resubmit using memcpy
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.
Looks like the typeof should work there too https://clang.llvm.org/docs/UsersManual.html
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.
@LuoZhongYao Please fix compliance issues, you commit title should be like: usb: device: fix unaligned memory access in Audio class
9bd8e37
to
8d75232
Compare
8d75232
to
cd2b4ae
Compare
Use UNALIGNED_*, sys_get_* to fix unaligned memory access issues Signed-off-by: ZhongYao Luo <[email protected]>
cd2b4ae
to
dd76422
Compare
@jfischer-no this has been addressed - please revisit |
Use
UNALIGNED_*
,sys_get_*
to fix unaligned memory access issuesfix #78920