diff --git a/system/stack/gatt/gatt_utils.cc b/system/stack/gatt/gatt_utils.cc index 1311500d65ea9d56f755393da701e0d2617a6307..25f4e13342768daf5a4a40e7d47da137dbbfdc66 100644 --- a/system/stack/gatt/gatt_utils.cc +++ b/system/stack/gatt/gatt_utils.cc @@ -1630,10 +1630,12 @@ uint8_t* gatt_dbg_op_name(uint8_t op_code) { pseduo_op_code_idx = 0x15; /* just an index to op_code_name */ } - if (pseduo_op_code_idx <= GATT_OP_CODE_MAX) + #define ARR_SIZE(a) (sizeof(a)/sizeof(a[0])) + if (pseduo_op_code_idx < ARR_SIZE(op_code_name)) return (uint8_t*)op_code_name[pseduo_op_code_idx]; else return (uint8_t*)"Op Code Exceed Max"; + #undef ARR_SIZE } /** Remove the application interface for the specified background device */