Commit 30a8f361 authored by James Vecore's avatar James Vecore Committed by Commit Bot

[Nearby] Fix role init for BT profile

Due to some subtle C++ rules, BluetoothProfileManagerClient::Options'
role field was not being initialized to the default value. This ended up
working correctly most of the time by chance, but we have see the role
of CLIENT go over d-bus when there is no reference to ever setting in
the code. See this article for the subtle details:

https://abseil.io/tips/146

Specifically section "A Digression Discerning Defaulted Default
Constructor Declarations". Because the ctor was defined in the .cc
file it is considered a "user-defined" ctor (even though it is
defaulted) and thus scalar members are not explicitly initialized.


Bug: b:173832484
Change-Id: Iaf518d903f219128e5832b2a793ce092b02733ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2561261
Commit-Queue: James Vecore <vecore@google.com>
Commit-Queue: Sonny Sasaka <sonnysasaka@chromium.org>
Auto-Submit: James Vecore <vecore@google.com>
Reviewed-by: default avatarSonny Sasaka <sonnysasaka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#831107}
parent 42f3f9c2
......@@ -42,7 +42,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothProfileManagerClient
std::unique_ptr<std::string> service;
// Role.
enum ProfileRole role;
enum ProfileRole role = ProfileRole::SYMMETRIC;
// RFCOMM channel number.
std::unique_ptr<uint16_t> channel;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment