Apply missing changes 18/128018/2
authorSeungyoun Ju <sy39.ju@samsung.com>
Thu, 4 May 2017 04:31:20 +0000 (13:31 +0900)
committerSeungyoun Ju <sy39.ju@samsung.com>
Thu, 4 May 2017 08:10:20 +0000 (17:10 +0900)
[Model] COMMON
[BinType] AP
[Customer] OPEN

[Issue#] N/A
[Request] Internal
[Occurrence Version] N/A

[Problem] bt_socket_connection_s is not initialized. And
__get_write_prop() is misused.
[Cause & Measure] Initialize bt_socket_connection_s and fix
 bt_gatt_characteristic_set_write_type() logic
[Checking Method] Code review

[Team] Basic connection
[Developer] Seungyoun Ju
[Solution company] Samsung
[Change Type] Specification change

Change-Id: I9018b3ace3b4ea2f711105a6cf950ac8035c9b2a

src/bluetooth-common.c
src/bluetooth-gatt.c

index 23038ccf2fa180becf67142ee3347d6e77a3e5d6..097bbce487119d10e8b373a62a3b33564aa61917 100644 (file)
@@ -1351,6 +1351,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
                else
                        error_code = _bt_get_error_code(param->result);
 
+               memset(&rfcomm_connection, 0x00, sizeof(bt_socket_connection_s));
                connection_ind = (bluetooth_rfcomm_connection_t *)(param->param_data);
 
                if (connection_ind) {
@@ -1384,6 +1385,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
        case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED:
                BT_INFO("bt_socket_connection_state_changed_cb() will be called with BT_SOCKET_DISCONNECTED");
 
+               memset(&rfcomm_connection, 0x00, sizeof(bt_socket_connection_s));
                disconnection_ind = (bluetooth_rfcomm_disconnection_t *)(param->param_data);
 
                if (disconnection_ind) {
index 9c4fe733e568d0949401b255b1edce127b39f31e..8f1fa1d1bdb4103934a72fc54729d717dab081d3 100644 (file)
@@ -2143,24 +2143,13 @@ int bt_gatt_characteristic_set_write_type(bt_gatt_h characteristic,
                return BT_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_LINE */
        }
 
-       switch (write_type) {
-       case BT_GATT_WRITE_TYPE_WRITE:
-               property = BT_GATT_PROPERTY_WRITE;
-               break;
-       case BT_GATT_WRITE_TYPE_WRITE_NO_RESPONSE:
-               property = BT_GATT_PROPERTY_WRITE_WITHOUT_RESPONSE;
-               break;
-       default:
+       ret = __get_write_prop(write_type, &property);
+       if (ret != BT_ERROR_NONE)
                return BT_ERROR_NOT_SUPPORTED;
-       }
 
        if (!(chr->properties & property))
                return BT_ERROR_NOT_SUPPORTED;
 
-       ret = __get_write_prop(write_type, &property);
-       if (ret != BT_ERROR_NONE)
-               return BT_ERROR_NOT_SUPPORTED;
-
        chr->write_type = write_type;
        return BT_ERROR_NONE;
 }