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

Use sizeof(uin32_t) when configuring HCI command packet #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benjaminjrood
Copy link

This patch configures the uim-sysfs daemon to use the sizeof(uint32_t) statement when configuring the HCI command packet, specifically the packet payload length field. The bit width of 'unsigned long' can differ between 32-bit and 64-bit platforms (specifically: 4 bytes for 32-bit, 8 bytes for 64-bit) and result in an incorrect payload length in the HCI command packet header. This causes the Bluetooth chip to not respond to the command, resulting in the chip not being configured at all and ultimately non-functional Bluetooth.

So, the lesson here is to ALWAYS USE EXPLICIT TYPE SIZES if the bit width of the type matters, as it does here.

This patch configures the uim-sysfs daemon to use the sizeof(uint32_t)
statement when configuring the HCI command packet, specifically the
packet payload length field.  The bit width of 'unsigned long' can
differ between 32-bit and 64-bit platforms (specifically: 4 bytes for
32-bit, 8 bytes for 64-bit) and result in an incorrect payload length
in the HCI command packet header.  This causes the Bluetooth chip to not
respond to the command, resulting in the chip not being configured at
all and ultimately non-functional Bluetooth.

So, the lesson here is to ALWAYS USE EXPLICIT TYPE SIZES if the bit
width of the type matters, as it does here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant