Fix scan device found callback unset issue 52/216452/2 accepted/tizen/unified/20191101.042108 submit/tizen/20191031.005137
authorWootak Jung <wootak.jung@samsung.com>
Fri, 25 Oct 2019 04:57:39 +0000 (13:57 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Fri, 25 Oct 2019 05:07:00 +0000 (14:07 +0900)
callback should be not unset if operation is failed

Change-Id: I22c1269b80d803e03ab659b2c211c6c162417746

src/bluetooth-adapter.c

index 1777f25..e112d84 100644 (file)
@@ -2875,13 +2875,14 @@ int bt_adapter_le_start_scan(bt_adapter_le_scan_result_cb cb, void *user_data)
        BT_CHECK_INPUT_PARAMETER(cb);
 
        _bt_le_adapter_init();
-       _bt_set_cb(BT_EVENT_LE_SCAN_RESULT_UPDATED, cb, user_data);
 
        error_code = _bt_get_error_code(bluetooth_start_le_discovery());
        if (error_code != BT_ERROR_NONE) {
-               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code),
-                                       error_code); /* LCOV_EXCL_LINE */
+               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); /* LCOV_EXCL_LINE */
+               return error_code;
        }
+
+       _bt_set_cb(BT_EVENT_LE_SCAN_RESULT_UPDATED, cb, user_data);
        return error_code;
 }
 
@@ -2894,13 +2895,12 @@ int bt_adapter_le_stop_scan(void)
 
        error_code = _bt_get_error_code(bluetooth_stop_le_discovery());
        if (error_code != BT_ERROR_NONE) {
-               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code),
-                                       error_code); /* LCOV_EXCL_LINE */
+               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); /* LCOV_EXCL_LINE */
+               return error_code;
        }
 
        _bt_unset_cb(BT_EVENT_LE_SCAN_RESULT_UPDATED);
        _bt_le_adapter_deinit();
-
        return error_code;
 }