From 44f3ee65934024c6c0fb854ddfccab12921daedd Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Wed, 9 Sep 2020 08:39:48 -0700 Subject: [PATCH] Remove #def code conditional BT_MAX_SERVICE_NAME_LEN Ok for constants, poor for code conditionals Towards readable code Bug: 163134718 Tag: #refactor Test: compile & verify basic functions working Test: acts -tc BleCocTest Change-Id: I1e3c7848932ba160411c86243b374d7b5f84403c --- stack/btm/btm_sec.cc | 11 ----------- stack/btm/security_device_record.h | 2 -- 2 files changed, 13 deletions(-) diff --git a/stack/btm/btm_sec.cc b/stack/btm/btm_sec.cc index dc784af04..64c7ca690 100644 --- a/stack/btm/btm_sec.cc +++ b/stack/btm/btm_sec.cc @@ -390,7 +390,6 @@ bool BTM_SetSecurityLevel(bool is_originator, const char* p_name, for (index = 0; index < BTM_SEC_MAX_SERVICE_RECORDS; index++, p_srec++) { /* Check if there is already a record for this service */ if (p_srec->security_flags & BTM_SEC_IN_USE) { -#if BT_MAX_SERVICE_NAME_LEN > 0 if (p_srec->psm == psm && p_srec->mx_proto_id == mx_proto_id && service_id == p_srec->service_id && p_name && (!strncmp(p_name, (char*)p_srec->orig_service_name, @@ -399,10 +398,6 @@ bool BTM_SetSecurityLevel(bool is_originator, const char* p_name, !strncmp(p_name, (char*)p_srec->term_service_name, /* strlcpy replaces end char with termination char*/ BT_MAX_SERVICE_NAME_LEN - 1))) -#else - if (p_srec->psm == psm && p_srec->mx_proto_id == mx_proto_id && - service_id == p_srec->service_id) -#endif { record_allocated = true; break; @@ -435,10 +430,8 @@ bool BTM_SetSecurityLevel(bool is_originator, const char* p_name, if (is_originator) { p_srec->orig_mx_chan_id = mx_chan_id; -#if BT_MAX_SERVICE_NAME_LEN > 0 strlcpy((char*)p_srec->orig_service_name, p_name, BT_MAX_SERVICE_NAME_LEN + 1); -#endif /* clear out the old setting, just in case it exists */ { p_srec->security_flags &= @@ -466,10 +459,8 @@ bool BTM_SetSecurityLevel(bool is_originator, const char* p_name, btm_cb.p_out_serv = p_srec; } else { p_srec->term_mx_chan_id = mx_chan_id; -#if BT_MAX_SERVICE_NAME_LEN > 0 strlcpy((char*)p_srec->term_service_name, p_name, BT_MAX_SERVICE_NAME_LEN + 1); -#endif /* clear out the old setting, just in case it exists */ { p_srec->security_flags &= ~( @@ -498,11 +489,9 @@ bool BTM_SetSecurityLevel(bool is_originator, const char* p_name, "BTM_SEC_REG[%d]: id %d, is_orig %d, psm 0x%04x, proto_id %d, chan_id %d", index, service_id, is_originator, psm, mx_proto_id, mx_chan_id); -#if BT_MAX_SERVICE_NAME_LEN > 0 BTM_TRACE_API( " : sec: 0x%x, service name [%s] (up to %d chars saved)", p_srec->security_flags, p_name, BT_MAX_SERVICE_NAME_LEN); -#endif return (record_allocated); } diff --git a/stack/btm/security_device_record.h b/stack/btm/security_device_record.h index 06052e3ec..ae5d61f46 100644 --- a/stack/btm/security_device_record.h +++ b/stack/btm/security_device_record.h @@ -63,10 +63,8 @@ typedef struct { uint16_t psm; /* L2CAP PSM value */ uint16_t security_flags; /* Bitmap of required security features */ uint8_t service_id; /* Passed in authorization callback */ -#if BT_MAX_SERVICE_NAME_LEN > 0 uint8_t orig_service_name[BT_MAX_SERVICE_NAME_LEN + 1]; uint8_t term_service_name[BT_MAX_SERVICE_NAME_LEN + 1]; -#endif } tBTM_SEC_SERV_REC; /* LE Security information of device in Slave Role */ -- 2.11.0