Closed Bug 944293 Opened 11 years ago Closed 11 years ago

[Bluetooth] Correct IS_PERIPHERAL COD and add error handling if COD is invalid

Categories

(Firefox OS Graveyard :: Bluetooth, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(blocking-b2g:-)

RESOLVED FIXED
blocking-b2g -

People

(Reporter: shawnjohnjr, Assigned: shawnjohnjr)

References

Details

Attachments

(1 file, 3 obsolete files)

[Bluetooth] Correct IS_PERIPHERAL COD and add error handling if COD is invalid.
Peripheral bit mask shall be 0x0500 instead of 0xA. And we also need to handle if NS_ENSURE_TRUE_VOID(hasAudio || hasRendering || isPeripheral).

There will be SIGSEGV when mProfiles[mProfilesIndex].
Attachment #8339892 - Flags: review?(gyeh)
Comment on attachment 8339892 [details] [diff] [review]
Bug 944293 - [Bluetooth] Correct IS_PERIPHERAL COD and add error handling if COD is invalid

Review of attachment 8339892 [details] [diff] [review]:
-----------------------------------------------------------------

Please check my following comments.

::: dom/bluetooth/BluetoothProfileController.h
@@ +25,5 @@
>   * https://www.bluetooth.org/en-us/specification/assigned-numbers/baseband
>   */
>  
>  // Bit 23 ~ Bit 13: Major service class
> +#define GET_MAJOR_SERVICE_CLASS(cod) (cod & 0xffe000)

This macro is used to retrieve the value of major service class from CoD, so I think we should still keep the shift operations.

@@ +30,3 @@
>  
>  // Bit 12 ~ Bit 8: Major device class
> +#define GET_MAJOR_DEVICE_CLASS(cod)  (cod & 0x1f00)

ditto.

@@ +39,5 @@
>  
>  // Bit 18: Major service class = 0x20, Rendering
>  #define HAS_RENDERING(cod)           (cod & 0x40000)
>  
> +// Major device class = 0x0500, Peripheral

Well, the major device class should be 0x5 for Peripheral device.
Attachment #8339892 - Attachment is obsolete: true
Attachment #8339892 - Flags: review?(gyeh)
Attachment #8340221 - Flags: review?(gyeh)
Comment on attachment 8340221 [details] [diff] [review]
Bug 944293 - [Bluetooth] Correct IS_PERIPHERAL COD and add error handling if COD is invalid

Review of attachment 8340221 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/bluetooth/BluetoothProfileController.h
@@ +40,5 @@
>  // Bit 18: Major service class = 0x20, Rendering
>  #define HAS_RENDERING(cod)           (cod & 0x40000)
>  
> +// Major device class = 0x5, Peripheral
> +#define IS_PERIPHERAL(cod)           (GET_MAJOR_DEVICE_CLASS(cod) & 0x5)

We'd like to ensure that the major device class is exactly 0x5.

For example, if the major device class is 0x4, the above macro returns 0x4, which means that the device is a peripheral device since (0x4  > 0). Does it make sense?
Attachment #8340221 - Attachment is obsolete: true
Attachment #8340221 - Flags: review?(gyeh)
Attachment #8340244 - Flags: review?(gyeh)
Attachment #8340244 - Attachment description: Bug944293.patch → Bug 944293 - [Bluetooth] Correct IS_PERIPHERAL COD and add error handling if COD is invalid
Sorry, I made a Monkey-like patch :(. You're right!
Comment on attachment 8340244 [details] [diff] [review]
Bug 944293 - [Bluetooth] Correct IS_PERIPHERAL COD and add error handling if COD is invalid

Review of attachment 8340244 [details] [diff] [review]:
-----------------------------------------------------------------

Yeah!
Attachment #8340244 - Flags: review?(gyeh) → review+
OS: Linux → Gonk (Firefox OS)
Hardware: x86_64 → ARM
https://hg.mozilla.org/mozilla-central/rev/66db2bb82088
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
blocking-b2g: --- → koi?
triage: minus as this is related to HID which is not part of the feature
blocking-b2g: koi? → -
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: