Bluetooth: Remove unnecessary error checks for bt_uart_read() calls

When the 'len' and 'min' parameters passed to bt_uart_read() are equal
the function is guaranteed to always return 'len' (it will keep
looping until that). This patch removes bt_uart_read() error checks
which would never occur in practice.

Change-Id: Icd879f1e15c6d33acc549155aabd24490098ffc5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2015-04-29 14:43:48 +03:00 committed by Anas Nashif
parent 099ecbfa7c
commit caf5141de5

View file

@ -91,14 +91,9 @@ static struct bt_buf *bt_uart_evt_recv(int *remaining)
{ {
struct bt_hci_evt_hdr hdr; struct bt_hci_evt_hdr hdr;
struct bt_buf *buf; struct bt_buf *buf;
int read;
read = bt_uart_read(UART, (void *)&hdr, sizeof(hdr), sizeof(hdr)); /* We can ignore the return value since we pass len == min */
if (read != sizeof(hdr)) { bt_uart_read(UART, (void *)&hdr, sizeof(hdr), sizeof(hdr));
BT_ERR("Cannot read event header\n");
*remaining = -EIO;
return NULL;
}
*remaining = hdr.len; *remaining = hdr.len;
@ -117,14 +112,9 @@ static struct bt_buf *bt_uart_acl_recv(int *remaining)
{ {
struct bt_hci_acl_hdr hdr; struct bt_hci_acl_hdr hdr;
struct bt_buf *buf; struct bt_buf *buf;
int read;
read = bt_uart_read(UART, (void *)&hdr, sizeof(hdr), sizeof(hdr)); /* We can ignore the return value since we pass len == min */
if (read != sizeof(hdr)) { bt_uart_read(UART, (void *)&hdr, sizeof(hdr), sizeof(hdr));
BT_ERR("Cannot read ACL header\n");
*remaining = -EIO;
return NULL;
}
buf = bt_buf_get(BT_ACL_IN, 0); buf = bt_buf_get(BT_ACL_IN, 0);
if (buf) if (buf)
@ -180,12 +170,6 @@ void bt_uart_isr(void *unused)
return; return;
} }
if (remaining < 0) {
BT_ERR("Corrupted data received\n");
remaining = 0;
return;
}
if (remaining > bt_buf_tailroom(buf)) { if (remaining > bt_buf_tailroom(buf)) {
BT_ERR("Not enough space in buffer\n"); BT_ERR("Not enough space in buffer\n");
goto failed; goto failed;