summaryrefslogtreecommitdiffstats
path: root/halimpl
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
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')
-rw-r--r--halimpl/bcm2079x/adaptation/patchram.cpp15
-rw-r--r--halimpl/bcm2079x/adaptation/userial_linux.c11
-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
-rw-r--r--halimpl/pn54x/Android.bp0
-rw-r--r--halimpl/pn54x/utils/phNxpConfig.cpp3
11 files changed, 55 insertions, 34 deletions
diff --git a/halimpl/bcm2079x/adaptation/patchram.cpp b/halimpl/bcm2079x/adaptation/patchram.cpp
index cb03d25..f4f01ac 100644
--- a/halimpl/bcm2079x/adaptation/patchram.cpp
+++ b/halimpl/bcm2079x/adaptation/patchram.cpp
@@ -135,7 +135,8 @@ static long getFileLength(FILE* fp) {
static bool isFileExist(const char* pFilename) {
FILE* pf;
- if ((pf = fopen(pFilename, "r")) != NULL) {
+ pf = fopen(pFilename, "r");
+ if (pf != NULL) {
fclose(pf);
return TRUE;
}
@@ -391,10 +392,12 @@ static void StartPatchDownload(uint32_t chipid) {
FILE* fd;
/* If an I2C fix patch file was specified, then tell the stack about it */
if (sPrePatchFn[0] != '\0') {
- if ((fd = fopen(sPrePatchFn, "rb")) != NULL) {
+ fd = fopen(sPrePatchFn, "rb");
+ if (fd != NULL) {
uint32_t lenPrmBuffer = getFileLength(fd);
- if ((sI2cFixPrmBuf = malloc(lenPrmBuffer)) != NULL) {
+ sI2cFixPrmBuf = malloc(lenPrmBuffer);
+ if (sI2cFixPrmBuf != NULL) {
size_t actualLen = fread(sI2cFixPrmBuf, 1, lenPrmBuffer, fd);
if (actualLen == lenPrmBuffer) {
ALOGD("%s Setting I2C fix to %s (size: %lu)", __func__, sPrePatchFn,
@@ -424,11 +427,13 @@ static void StartPatchDownload(uint32_t chipid) {
uint32_t bDownloadStarted = false;
/* open patchfile, read it into a buffer */
- if ((fd = fopen(sPatchFn, "rb")) != NULL) {
+ fd = fopen(sPatchFn, "rb");
+ if (fd != NULL) {
uint32_t lenPrmBuffer = getFileLength(fd);
ALOGD("%s Downloading patchfile %s (size: %lu) format=%u", __func__,
sPatchFn, lenPrmBuffer, NFC_HAL_PRM_FORMAT_NCD);
- if ((sPrmBuf = malloc(lenPrmBuffer)) != NULL) {
+ sPrmBuf = malloc(lenPrmBuffer);
+ if (sPrmBuf != NULL) {
size_t actualLen = fread(sPrmBuf, 1, lenPrmBuffer, fd);
if (actualLen == lenPrmBuffer) {
if (!SpdHelper::isPatchBad((uint8_t*)sPrmBuf, lenPrmBuffer)) {
diff --git a/halimpl/bcm2079x/adaptation/userial_linux.c b/halimpl/bcm2079x/adaptation/userial_linux.c
index d7469d9..3313a2e 100644
--- a/halimpl/bcm2079x/adaptation/userial_linux.c
+++ b/halimpl/bcm2079x/adaptation/userial_linux.c
@@ -743,7 +743,8 @@ uint32_t userial_read_thread(uint32_t arg) {
NFC_HDR* p_buf;
uint8_t* current_packet;
- if ((p_buf = (NFC_HDR*)GKI_getpoolbuf(USERIAL_POOL_ID)) != NULL) {
+ p_buf = (NFC_HDR*)GKI_getpoolbuf(USERIAL_POOL_ID);
+ if (p_buf != NULL) {
p_buf->offset = 0;
p_buf->layer_specific = 0;
@@ -1012,7 +1013,8 @@ void USERIAL_Open(tUSERIAL_PORT port, tUSERIAL_OPEN_CFG* p_cfg,
{
ALOGD("%s Opening %s\n", __func__, device_name);
- if ((linux_cb.sock = open((char*)device_name, O_RDWR | O_NOCTTY)) == -1) {
+ linux_cb.sock = open((char*)device_name, O_RDWR | O_NOCTTY);
+ if (linux_cb.sock == -1) {
ALOGI("%s unable to open %s", __func__, device_name);
GKI_send_event(NFC_HAL_TASK, NFC_HAL_TASK_EVT_TERMINATE);
goto done_open;
@@ -1024,8 +1026,9 @@ void USERIAL_Open(tUSERIAL_PORT port, tUSERIAL_OPEN_CFG* p_cfg,
if (strcmp(power_control_dev, userial_dev) == 0)
linux_cb.sock_power_control = linux_cb.sock;
else {
- if ((linux_cb.sock_power_control =
- open((char*)power_control_dev, O_RDWR | O_NOCTTY)) == -1) {
+ linux_cb.sock_power_control =
+ open((char*)power_control_dev, O_RDWR | O_NOCTTY);
+ if (linux_cb.sock_power_control == -1) {
ALOGI("%s unable to open %s", __func__, power_control_dev);
}
}
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;
diff --git a/halimpl/pn54x/Android.bp b/halimpl/pn54x/Android.bp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/halimpl/pn54x/Android.bp
diff --git a/halimpl/pn54x/utils/phNxpConfig.cpp b/halimpl/pn54x/utils/phNxpConfig.cpp
index c6576e0..aa73627 100644
--- a/halimpl/pn54x/utils/phNxpConfig.cpp
+++ b/halimpl/pn54x/utils/phNxpConfig.cpp
@@ -686,7 +686,8 @@ int CNfcConfig::updateTimestamp() {
if (stat(config_timestamp_path, &st) != 0) {
ALOGD("%s file %s not exist, creat it.\n", __func__, config_timestamp_path);
- if ((fd = fopen(config_timestamp_path, "w+")) != NULL) {
+ fd = fopen(config_timestamp_path, "w+");
+ if (fd != NULL) {
fwrite(&m_timeStamp, sizeof(unsigned long), 1, fd);
fclose(fd);
}