OSDN Git Service

booleans are a thing for a reason
authorZach Johnson <zachoverflow@google.com>
Fri, 28 Aug 2020 22:18:43 +0000 (15:18 -0700)
committerZach Johnson <zachoverflow@google.com>
Fri, 28 Aug 2020 22:18:43 +0000 (15:18 -0700)
so don't create an enum that looks like
a boolean and doesn't add any helpful context

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I1b43513dd49e1bec17695783cb5e370f306892fc

bta/sdp/bta_sdp_act.cc
bta/sdp/bta_sdp_int.h

index 52e091a..f4af4be 100644 (file)
@@ -328,7 +328,7 @@ static void bta_sdp_search_cback(uint16_t result, void* user_data) {
   int count = 0;
   APPL_TRACE_DEBUG("%s() -  res: 0x%x", __func__, result);
 
-  bta_sdp_cb.sdp_active = BTA_SDP_ACTIVE_NONE;
+  bta_sdp_cb.sdp_active = false;
 
   if (bta_sdp_cb.p_dm_cback == NULL) return;
 
@@ -423,7 +423,7 @@ void bta_sdp_search(const RawAddress bd_addr, const bluetooth::Uuid uuid) {
 
   APPL_TRACE_DEBUG("%s in, sdp_active:%d", __func__, bta_sdp_cb.sdp_active);
 
-  if (bta_sdp_cb.sdp_active != BTA_SDP_ACTIVE_NONE) {
+  if (bta_sdp_cb.sdp_active) {
     /* SDP is still in progress */
     status = BTA_SDP_BUSY;
     if (bta_sdp_cb.p_dm_cback) {
@@ -439,7 +439,7 @@ void bta_sdp_search(const RawAddress bd_addr, const bluetooth::Uuid uuid) {
     return;
   }
 
-  bta_sdp_cb.sdp_active = BTA_SDP_ACTIVE_YES;
+  bta_sdp_cb.sdp_active = true;
   bta_sdp_cb.remote_addr = bd_addr;
 
   /* initialize the search for the uuid */
@@ -453,7 +453,7 @@ void bta_sdp_search(const RawAddress bd_addr, const bluetooth::Uuid uuid) {
   if (!SDP_ServiceSearchAttributeRequest2(bd_addr, p_bta_sdp_cfg->p_sdp_db,
                                           bta_sdp_search_cback,
                                           (void*)bta_sdp_search_uuid)) {
-    bta_sdp_cb.sdp_active = BTA_SDP_ACTIVE_NONE;
+    bta_sdp_cb.sdp_active = false;
 
     /* failed to start SDP. report the failure right away */
     if (bta_sdp_cb.p_dm_cback) {
index e85e444..163462b 100644 (file)
  *  Constants
  ****************************************************************************/
 
-enum {
-  BTA_SDP_ACTIVE_NONE = 0,
-  BTA_SDP_ACTIVE_YES /* waiting for SDP result */
-};
-
 /* SDP control block */
 typedef struct {
-  uint8_t sdp_active; /* see BTA_SDP_SDP_ACT_* */
+  bool sdp_active;
   RawAddress remote_addr;
   tBTA_SDP_DM_CBACK* p_dm_cback;
 } tBTA_SDP_CB;