summaryrefslogtreecommitdiffstats
path: root/halimpl/bcm2079x/hal
diff options
context:
space:
mode:
authorRuchi Kandoi <kandoiruchi@google.com>2017-01-30 17:48:41 -0800
committerRuchi Kandoi <kandoiruchi@google.com>2017-03-06 20:42:30 +0000
commit0c515ae1d2edf9202878a7ac7bcbf195333643e5 (patch)
tree7bd72e1f0fde3ed6c1444cd5e912db97924fb9df /halimpl/bcm2079x/hal
parent6fca02d5010de7bd31d83b853c32138021da5f29 (diff)
downloadandroid_hardware_broadcom_nfc-0c515ae1d2edf9202878a7ac7bcbf195333643e5.tar.gz
android_hardware_broadcom_nfc-0c515ae1d2edf9202878a7ac7bcbf195333643e5.tar.bz2
android_hardware_broadcom_nfc-0c515ae1d2edf9202878a7ac7bcbf195333643e5.zip
Readability fix: if statement assignments
Coccinelle-assisted: @@ variable i; expression E; statement S1, S2; @@ + i = E; if ( ( - (i = E) + i != ... | - (i = E) + i == ... | - (i = E) + i < ... | - (i = E) + i > ... | - (i = E) + i <= ... | - (i = E) + i >= ... | - (i = E) + i ) ) S1 else S2 spatch --sp-file if_assignment.cocci --in-place --dir . find * | grep "\.[ch]" | xargs clang-format --style=file -i Test: Compiles Change-Id: Ifb9cde410ed84e0ab8012432ad0ec30df17d1786 Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Diffstat (limited to 'halimpl/bcm2079x/hal')
-rw-r--r--halimpl/bcm2079x/hal/hal/nfc_hal_api.c12
-rw-r--r--halimpl/bcm2079x/hal/hal/nfc_hal_dm.c10
-rw-r--r--halimpl/bcm2079x/hal/hal/nfc_hal_hci.c13
-rw-r--r--halimpl/bcm2079x/hal/hal/nfc_hal_hci_ci.c8
-rw-r--r--halimpl/bcm2079x/hal/hal/nfc_hal_main.c6
-rw-r--r--halimpl/bcm2079x/hal/hal/nfc_hal_nci.c8
-rw-r--r--halimpl/bcm2079x/hal/hal/nfc_hal_prm.c3
7 files changed, 36 insertions, 24 deletions
diff --git a/halimpl/bcm2079x/hal/hal/nfc_hal_api.c b/halimpl/bcm2079x/hal/hal/nfc_hal_api.c
index 73573f8..b40bcc4 100644
--- a/halimpl/bcm2079x/hal/hal/nfc_hal_api.c
+++ b/halimpl/bcm2079x/hal/hal/nfc_hal_api.c
@@ -152,7 +152,8 @@ void HAL_NfcCoreInitialized(uint16_t data_len,
size = p_core_init_rsp_params[2] + NCI_MSG_HDR_SIZE;
/* Send message to NFC_HAL_TASK */
- if ((p_msg = (NFC_HDR*)GKI_getbuf((uint16_t)(size + NFC_HDR_SIZE))) != NULL) {
+ p_msg = (NFC_HDR*)GKI_getbuf((uint16_t)(size + NFC_HDR_SIZE));
+ if (p_msg != NULL) {
p_msg->event = NFC_HAL_EVT_POST_CORE_RESET;
p_msg->offset = 0;
p_msg->len = size;
@@ -187,7 +188,8 @@ void HAL_NfcWrite(uint16_t data_len, uint8_t* p_data) {
}
/* Send message to NFC_HAL_TASK */
- if ((p_msg = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID)) != NULL) {
+ p_msg = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID);
+ if (p_msg != NULL) {
p_msg->event = NFC_HAL_EVT_TO_NFC_NCI;
p_msg->offset = NFC_HAL_NCI_MSG_OFFSET_SIZE;
p_msg->len = data_len;
@@ -227,7 +229,8 @@ bool HAL_NfcPreDiscover(void) {
if (p_nfc_hal_pre_discover_cfg && *p_nfc_hal_pre_discover_cfg) {
status = true;
/* Send message to NFC_HAL_TASK */
- if ((p_msg = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID)) != NULL) {
+ p_msg = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID);
+ if (p_msg != NULL) {
p_msg->event = NFC_HAL_EVT_PRE_DISCOVER;
GKI_send_msg(NFC_HAL_TASK, NFC_HAL_TASK_MBOX, p_msg);
}
@@ -260,7 +263,8 @@ void HAL_NfcControlGranted(void) {
HAL_TRACE_API0("HAL_NfcControlGranted ()");
/* Send message to NFC_HAL_TASK */
- if ((p_msg = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID)) != NULL) {
+ p_msg = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID);
+ if (p_msg != NULL) {
p_msg->event = NFC_HAL_EVT_CONTROL_GRANTED;
GKI_send_msg(NFC_HAL_TASK, NFC_HAL_TASK_MBOX, p_msg);
}
diff --git a/halimpl/bcm2079x/hal/hal/nfc_hal_dm.c b/halimpl/bcm2079x/hal/hal/nfc_hal_dm.c
index a07dfc9..b2fec1b 100644
--- a/halimpl/bcm2079x/hal/hal/nfc_hal_dm.c
+++ b/halimpl/bcm2079x/hal/hal/nfc_hal_dm.c
@@ -98,8 +98,8 @@ tHAL_NFC_STATUS nfc_hal_dm_set_config(uint8_t tlv_size, uint8_t* p_param_tlvs,
return status;
}
- if ((p_buff = (uint8_t*)GKI_getbuf(
- (uint16_t)(NCI_MSG_HDR_SIZE + tlv_size))) != NULL) {
+ p_buff = (uint8_t*)GKI_getbuf((uint16_t)(NCI_MSG_HDR_SIZE + tlv_size));
+ if (p_buff != NULL) {
p = p_buff;
NCI_MSG_BLD_HDR0(p, NCI_MT_CMD, NCI_GID_CORE);
@@ -843,7 +843,8 @@ void nfc_hal_dm_send_nci_cmd(const uint8_t* p_data, uint16_t len,
return;
}
- if ((p_buf = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID)) != NULL) {
+ p_buf = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID);
+ if (p_buf != NULL) {
nfc_hal_cb.ncit_cb.nci_wait_rsp = NFC_HAL_WAIT_RSP_VSC;
p_buf->offset = NFC_HAL_NCI_MSG_OFFSET_SIZE;
@@ -954,7 +955,8 @@ void nfc_hal_dm_send_bt_cmd(const uint8_t* p_data, uint16_t len,
return;
}
- if ((p_buf = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID)) != NULL) {
+ p_buf = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID);
+ if (p_buf != NULL) {
nfc_hal_cb.ncit_cb.nci_wait_rsp = NFC_HAL_WAIT_RSP_PROP;
p_buf->offset = NFC_HAL_NCI_MSG_OFFSET_SIZE;
diff --git a/halimpl/bcm2079x/hal/hal/nfc_hal_hci.c b/halimpl/bcm2079x/hal/hal/nfc_hal_hci.c
index 6c99253..1033327 100644
--- a/halimpl/bcm2079x/hal/hal/nfc_hal_hci.c
+++ b/halimpl/bcm2079x/hal/hal/nfc_hal_hci.c
@@ -157,8 +157,9 @@ void nfc_hal_hci_enable(void) {
((!nfc_hal_cb.hci_cb.hci_fw_workaround) ||
(nfc_hal_cb.nvm_cb.nvm_type == NCI_SPD_NVM_TYPE_EEPROM))) ||
(p_nfc_hal_cfg->nfc_hal_hci_uicc_support & HAL_NFC_HCI_UICC2_HOST)) {
- if ((p_hci_netwk_cmd = (uint8_t*)GKI_getbuf(
- NCI_MSG_HDR_SIZE + NFC_HAL_HCI_NETWK_INFO_SIZE)) == NULL) {
+ p_hci_netwk_cmd =
+ (uint8_t*)GKI_getbuf(NCI_MSG_HDR_SIZE + NFC_HAL_HCI_NETWK_INFO_SIZE);
+ if (p_hci_netwk_cmd == NULL) {
HAL_TRACE_ERROR0(
"nfc_hal_hci_enable: unable to allocate buffer for reading hci "
"network info from nvram");
@@ -312,7 +313,8 @@ void nfc_hal_hci_fake_adm_notify_all_pipe_cleared_to_dh(void) {
NFC_HAL_HCI_HOST_ID_UICC1);
/* Start of new message. Allocate a buffer for message */
- if ((p_msg = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID)) != NULL) {
+ p_msg = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID);
+ if (p_msg != NULL) {
/* Initialize NFC_HDR */
p_msg->len = NCI_DATA_HDR_SIZE + 0x03;
p_msg->event = 0;
@@ -744,8 +746,9 @@ void nfc_hal_hci_set_next_hci_netwk_config(uint8_t block) {
p_nfc_hal_cfg->nfc_hal_hci_uicc_support, nfc_hal_cb.nvm_cb.nvm_type);
case HC_F5_NV_BLOCK:
- if ((p_hci_netwk_cmd = (uint8_t*)GKI_getbuf(
- NCI_MSG_HDR_SIZE + NFC_HAL_HCI_DH_NETWK_INFO_SIZE)) == NULL) {
+ p_hci_netwk_cmd = (uint8_t*)GKI_getbuf(NCI_MSG_HDR_SIZE +
+ NFC_HAL_HCI_DH_NETWK_INFO_SIZE);
+ if (p_hci_netwk_cmd == NULL) {
HAL_TRACE_ERROR0(
"nfc_hal_hci_set_next_hci_netwk_config: unable to allocate buffer "
"for reading hci network info from nvram");
diff --git a/halimpl/bcm2079x/hal/hal/nfc_hal_hci_ci.c b/halimpl/bcm2079x/hal/hal/nfc_hal_hci_ci.c
index 3e92b5d..73bf6a5 100644
--- a/halimpl/bcm2079x/hal/hal/nfc_hal_hci_ci.c
+++ b/halimpl/bcm2079x/hal/hal/nfc_hal_hci_ci.c
@@ -44,8 +44,8 @@ void nfc_hal_nv_ci_read(uint16_t num_bytes_read, tNFC_HAL_NV_CO_STATUS status,
tNFC_HAL_HCI_EVENT_DATA* p_msg;
/* Send message to NCIT task */
- if ((p_msg = (tNFC_HAL_HCI_EVENT_DATA*)GKI_getbuf(
- sizeof(tNFC_HAL_HCI_EVENT_DATA))) != NULL) {
+ p_msg = (tNFC_HAL_HCI_EVENT_DATA*)GKI_getbuf(sizeof(tNFC_HAL_HCI_EVENT_DATA));
+ if (p_msg != NULL) {
p_msg->nv_read.hdr.event = NFC_HAL_HCI_RSP_NV_READ_EVT;
p_msg->hdr.offset = 0;
p_msg->hdr.len = sizeof(tNFC_HAL_HCI_RSP_NV_READ_EVT);
@@ -75,8 +75,8 @@ void nfc_hal_nv_ci_read(uint16_t num_bytes_read, tNFC_HAL_NV_CO_STATUS status,
void nfc_hal_nv_ci_write(tNFC_HAL_NV_CO_STATUS status) {
tNFC_HAL_HCI_EVENT_DATA* p_msg;
- if ((p_msg = (tNFC_HAL_HCI_EVENT_DATA*)GKI_getbuf(
- sizeof(tNFC_HAL_HCI_EVENT_DATA))) != NULL) {
+ p_msg = (tNFC_HAL_HCI_EVENT_DATA*)GKI_getbuf(sizeof(tNFC_HAL_HCI_EVENT_DATA));
+ if (p_msg != NULL) {
p_msg->nv_write.hdr.event = NFC_HAL_HCI_RSP_NV_WRITE_EVT;
p_msg->nv_write.hdr.offset = 0;
p_msg->nv_write.hdr.len = sizeof(tNFC_HAL_HCI_RSP_NV_READ_EVT);
diff --git a/halimpl/bcm2079x/hal/hal/nfc_hal_main.c b/halimpl/bcm2079x/hal/hal/nfc_hal_main.c
index 118f678..7b4e79b 100644
--- a/halimpl/bcm2079x/hal/hal/nfc_hal_main.c
+++ b/halimpl/bcm2079x/hal/hal/nfc_hal_main.c
@@ -372,7 +372,8 @@ void nfc_hal_main_start_quick_timer(TIMER_LIST_ENT* p_tle, uint16_t type,
/* if timer starts on other than NCIT task (script wrapper) */
if (GKI_get_taskid() != NFC_HAL_TASK) {
/* post event to start timer in NCIT task */
- if ((p_msg = (NFC_HDR*)GKI_getbuf(NFC_HDR_SIZE)) != NULL) {
+ p_msg = (NFC_HDR*)GKI_getbuf(NFC_HDR_SIZE);
+ if (p_msg != NULL) {
p_msg->event = NFC_HAL_EVT_TO_START_QUICK_TIMER;
GKI_send_msg(NFC_HAL_TASK, NFC_HAL_TASK_MBOX, p_msg);
}
@@ -476,7 +477,8 @@ static void nfc_hal_send_credit_ntf_for_cid(uint8_t cid) {
uint8_t *p, *ps;
/* Start of new message. Allocate a buffer for message */
- if ((p_msg = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID)) != NULL) {
+ p_msg = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID);
+ if (p_msg != NULL) {
/* Initialize NFC_HDR */
p_msg->len = NCI_DATA_HDR_SIZE + 0x03;
p_msg->event = 0;
diff --git a/halimpl/bcm2079x/hal/hal/nfc_hal_nci.c b/halimpl/bcm2079x/hal/hal/nfc_hal_nci.c
index 4dde9af..8d57eeb 100644
--- a/halimpl/bcm2079x/hal/hal/nfc_hal_nci.c
+++ b/halimpl/bcm2079x/hal/hal/nfc_hal_nci.c
@@ -178,8 +178,8 @@ static bool nfc_hal_nci_receive_nci_msg(tNFC_HAL_NCIT_CB* p_cb, uint8_t byte) {
p_cb->rcv_len = NCI_MSG_HDR_SIZE;
/* Start of new message. Allocate a buffer for message */
- if ((p_cb->p_rcv_msg = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID)) !=
- NULL) {
+ p_cb->p_rcv_msg = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID);
+ if (p_cb->p_rcv_msg != NULL) {
/* Initialize NFC_HDR */
p_cb->p_rcv_msg->len = 0;
p_cb->p_rcv_msg->event = 0;
@@ -268,8 +268,8 @@ static bool nfc_hal_nci_receive_bt_msg(tNFC_HAL_NCIT_CB* p_cb, uint8_t byte) {
p_cb->rcv_state = NFC_HAL_RCV_BT_HDR_ST;
p_cb->rcv_len = HCIE_PREAMBLE_SIZE;
- if ((p_cb->p_rcv_msg = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID)) !=
- NULL) {
+ p_cb->p_rcv_msg = (NFC_HDR*)GKI_getpoolbuf(NFC_HAL_NCI_POOL_ID);
+ if (p_cb->p_rcv_msg != NULL) {
/* Initialize NFC_HDR */
p_cb->p_rcv_msg->len = 0;
p_cb->p_rcv_msg->event = 0;
diff --git a/halimpl/bcm2079x/hal/hal/nfc_hal_prm.c b/halimpl/bcm2079x/hal/hal/nfc_hal_prm.c
index 1bf33e6..3d9e76f 100644
--- a/halimpl/bcm2079x/hal/hal/nfc_hal_prm.c
+++ b/halimpl/bcm2079x/hal/hal/nfc_hal_prm.c
@@ -622,7 +622,8 @@ static bool nfc_hal_prm_nvm_rw_cmd(void) {
}
cmd_len = len + 7;
- if ((p_buff = (uint8_t*)GKI_getbuf(cmd_len)) == NULL) {
+ p_buff = (uint8_t*)GKI_getbuf(cmd_len);
+ if (p_buff == NULL) {
HAL_TRACE_ERROR0("NVM No buffer");
nfc_hal_prm_spd_handle_download_complete(NFC_HAL_PRM_ABORT_EVT);
return true;