From 27eeafd652fe9a1b70e6eba25c93d996a2b1aa39 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Fri, 25 Oct 2013 17:14:58 +0200 Subject: [PATCH] android: Use common exit path for commands in bt_adapter_handle_cmd All adapter commands return no parameters so putting error and success response on common exit path. This will make function easier to follow when more commands support will be added. --- android/adapter.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/android/adapter.c b/android/adapter.c index ec90ccaa5..685b00da2 100644 --- a/android/adapter.c +++ b/android/adapter.c @@ -374,39 +374,37 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf, case HAL_OP_ENABLE: if (adapter->current_settings & MGMT_SETTING_POWERED) { status = HAL_STATUS_DONE; - break; + goto error; } - if (set_mode(MGMT_OP_SET_POWERED, 0x01)) { - ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL, - -1); - return; - } + if (!set_mode(MGMT_OP_SET_POWERED, 0x01)) + goto error; + break; case HAL_OP_DISABLE: if (!(adapter->current_settings & MGMT_SETTING_POWERED)) { status = HAL_STATUS_DONE; - break; + goto error; } - if (set_mode(MGMT_OP_SET_POWERED, 0x00)) { - ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL, - -1); - return; - } + if (!set_mode(MGMT_OP_SET_POWERED, 0x00)) + goto error; + break; case HAL_OP_GET_ADAPTER_PROP: - if (get_property(buf, len)) { - ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL, - -1); - return; - } + if (!get_property(buf, len)) + goto error; + break; default: DBG("Unhandled command, opcode 0x%x", opcode); - break; + goto error; } + ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL, -1); + return; + +error: ipc_send_rsp(io, HAL_SERVICE_ID_BLUETOOTH, status); } -- 2.47.3