Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32c2d771 authored by Chris Manton's avatar Chris Manton
Browse files

Replace #def BTM_SEC_SERVICE_NAME_LEN

BTM_SEC_SERVICE_NAME_LEN == BT_MAX_SERVICE_NAME_LEN

Use: BT_MAX_SERVICE_NAME_LEN

Towards readable code

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working
Test: acts -tc BleCocTest
Change-Id: I60e08e99d10cd2521beb7bbeaffe2263eabdd22d
parent 94a02891
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -361,7 +361,7 @@ void BTM_SetPinType(uint8_t pin_type, PIN_CODE pin_code, uint8_t pin_code_len) {
 * Parameters:      is_originator - true if originating the connection
 *                  p_name      - Name of the service relevant only if
 *                                authorization will show this name to user.
 *                                Ignored if BTM_SEC_SERVICE_NAME_LEN is 0.
 *                                Ignored if BT_MAX_SERVICE_NAME_LEN is 0.
 *                  service_id  - service ID for the service passed to
 *                                authorization callback
 *                  sec_level   - bit mask of the security features
@@ -390,15 +390,15 @@ 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 BTM_SEC_SERVICE_NAME_LEN > 0
#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,
                    /* strlcpy replaces end char with termination char*/
                    BTM_SEC_SERVICE_NAME_LEN - 1) ||
                    BT_MAX_SERVICE_NAME_LEN - 1) ||
           !strncmp(p_name, (char*)p_srec->term_service_name,
                    /* strlcpy replaces end char with termination char*/
                    BTM_SEC_SERVICE_NAME_LEN - 1)))
                    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)
@@ -435,9 +435,9 @@ bool BTM_SetSecurityLevel(bool is_originator, const char* p_name,

  if (is_originator) {
    p_srec->orig_mx_chan_id = mx_chan_id;
#if BTM_SEC_SERVICE_NAME_LEN > 0
#if BT_MAX_SERVICE_NAME_LEN > 0
    strlcpy((char*)p_srec->orig_service_name, p_name,
            BTM_SEC_SERVICE_NAME_LEN + 1);
            BT_MAX_SERVICE_NAME_LEN + 1);
#endif
/* clear out the old setting, just in case it exists */
    {
@@ -466,9 +466,9 @@ 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 BTM_SEC_SERVICE_NAME_LEN > 0
#if BT_MAX_SERVICE_NAME_LEN > 0
    strlcpy((char*)p_srec->term_service_name, p_name,
            BTM_SEC_SERVICE_NAME_LEN + 1);
            BT_MAX_SERVICE_NAME_LEN + 1);
#endif
/* clear out the old setting, just in case it exists */
    {
@@ -498,10 +498,10 @@ 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 BTM_SEC_SERVICE_NAME_LEN > 0
#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, BTM_SEC_SERVICE_NAME_LEN);
      p_srec->security_flags, p_name, BT_MAX_SERVICE_NAME_LEN);
#endif

  return (record_allocated);
+1 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ void BTM_SetPinType(uint8_t pin_type, PIN_CODE pin_code, uint8_t pin_code_len);
 * Parameters:      is_originator - true if originating the connection
 *                  p_name      - Name of the service relevant only if
 *                                authorization will show this name to user.
 *                                Ignored if BTM_SEC_SERVICE_NAME_LEN is 0.
 *                                Ignored if BT_MAX_SERVICE_NAME_LEN is 0.
 *                  service_id  - service ID for the service passed to
 *                                authorization callback
 *                  sec_level   - bit mask of the security features
+3 −3
Original line number Diff line number Diff line
@@ -63,9 +63,9 @@ 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 BTM_SEC_SERVICE_NAME_LEN > 0
  uint8_t orig_service_name[BTM_SEC_SERVICE_NAME_LEN + 1];
  uint8_t term_service_name[BTM_SEC_SERVICE_NAME_LEN + 1];
#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;