Bluetooth: Reduce hci_cmd_complete() stack usage

Instead of storing a pointer to the status (4 bytes) we can just copy
its value directly (1 byte). Since the previous variable is a 16-bit
opcode the smaller 1-byte variable should fit within the same 4-byte
word, saving 4 bytes from the stack.

Change-Id: I406c60c7b2563ba6397ab75cf1dbe3d346b6c0ed
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2015-12-09 14:13:14 +02:00 committed by Anas Nashif
commit 7493cadee7

View file

@ -1084,7 +1084,7 @@ static void hci_cmd_complete(struct net_buf *buf)
{
struct hci_evt_cmd_complete *evt = (void *)buf->data;
uint16_t opcode = sys_le16_to_cpu(evt->opcode);
uint8_t *status;
uint8_t status;
BT_DBG("opcode %x", opcode);
@ -1093,7 +1093,7 @@ static void hci_cmd_complete(struct net_buf *buf)
/* All command return parameters have a 1-byte status in the
* beginning, so we can safely make this generalization.
*/
status = buf->data;
status = buf->data[0];
switch (opcode) {
case BT_HCI_OP_RESET:
@ -1104,7 +1104,7 @@ static void hci_cmd_complete(struct net_buf *buf)
break;
}
hci_cmd_done(opcode, *status, buf);
hci_cmd_done(opcode, status, buf);
if (evt->ncmd && !bt_dev.ncmd) {
/* Allow next command to be sent */