From 1d519c69151310a3e6b180150faf7bbf9d79d627 Mon Sep 17 00:00:00 2001 From: Hemant Gupta Date: Tue, 28 Feb 2017 22:38:50 +0530 Subject: [PATCH] PAN: Fix issues reported by Static Analysis Tool Fix issues reported by Static Analysis Tool. Test: builds, PAN functionality works fine Bug: 35013844 Change-Id: I55e75fe5e522ab5c417557d4ef9a11723dfd0c3c --- bta/pan/bta_pan_ci.cc | 4 ++-- bta/pan/bta_pan_main.cc | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/bta/pan/bta_pan_ci.cc b/bta/pan/bta_pan_ci.cc index 82d6593e2..d2fda39a8 100644 --- a/bta/pan/bta_pan_ci.cc +++ b/bta/pan/bta_pan_ci.cc @@ -183,10 +183,10 @@ void bta_pan_ci_rx_writebuf(uint16_t handle, const RawAddress& dst, ******************************************************************************/ BT_HDR* bta_pan_ci_readbuf(uint16_t handle, RawAddress& src, RawAddress& dst, uint16_t* p_protocol, bool* p_ext, bool* p_forward) { - tBTA_PAN_SCB* p_scb; + tBTA_PAN_SCB* p_scb = bta_pan_scb_by_handle(handle); BT_HDR* p_buf; - p_scb = bta_pan_scb_by_handle(handle); + if (p_scb == NULL) return NULL; p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_scb->data_queue); if (p_buf != NULL) { diff --git a/bta/pan/bta_pan_main.cc b/bta/pan/bta_pan_main.cc index 17506a23b..09df88f2e 100644 --- a/bta/pan/bta_pan_main.cc +++ b/bta/pan/bta_pan_main.cc @@ -51,7 +51,8 @@ enum { BTA_PAN_CONN_OPEN, BTA_PAN_CONN_CLOSE, BTA_PAN_FREE_BUF, - BTA_PAN_IGNORE + BTA_PAN_IGNORE, + BTA_PAN_MAX_ACTIONS }; /* type for action functions */ @@ -184,11 +185,9 @@ static void bta_pan_sm_execute(tBTA_PAN_SCB* p_scb, uint16_t event, /* execute action functions */ for (i = 0; i < BTA_PAN_ACTIONS; i++) { action = state_table[event][i]; - if (action != BTA_PAN_IGNORE) { - (*bta_pan_action[action])(p_scb, p_data); - } else { - break; - } + CHECK(action < BTA_PAN_MAX_ACTIONS); + if (action == BTA_PAN_IGNORE) continue; + (*bta_pan_action[action])(p_scb, p_data); } } -- 2.11.0