diff options
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | examples/CMakeLists.txt | 6 | ||||
-rw-r--r-- | examples/checkinit.cpp | 41 | ||||
-rw-r--r-- | src/BluetoothManager.cpp | 9 |
4 files changed, 53 insertions, 5 deletions
diff --git a/.travis.yml b/.travis.yml index 09fd991d..10a0a13b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ compiler: matrix: exclude: - compiler: clang - - env: COVERITY_SCAN_BRANCH=1 + env: TRAVIS_BRANCH=coverity_scan env: global: diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d6995c28..f80f620e 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,6 +11,12 @@ set_target_properties(hellotinyb PROPERTIES CXX_STANDARD 11) +add_executable (checkinit checkinit.cpp) +set_target_properties(checkinit + PROPERTIES + CXX_STANDARD 11) + include_directories(${PROJECT_SOURCE_DIR}/api) target_link_libraries (hellotinyb tinyb) +target_link_libraries (checkinit tinyb) diff --git a/examples/checkinit.cpp b/examples/checkinit.cpp new file mode 100644 index 00000000..fe4d47dd --- /dev/null +++ b/examples/checkinit.cpp @@ -0,0 +1,41 @@ +/* + * Author: Petre Eftime <[email protected]> + * Copyright (c) 2015 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include <tinyb.hpp> +#include <iostream> + +using namespace tinyb; + +int main(int argc, char **argv) +{ + try { + BluetoothManager *manager = BluetoothManager::get_bluetooth_manager(); + } catch(const std::runtime_error& e) { + std::cout << "Expected error: " << e.what() << std::endl; + return 1; + } + + std::cout << "Initialization was succesful." << std::endl; + return 0; +} diff --git a/src/BluetoothManager.cpp b/src/BluetoothManager.cpp index b0338242..7cf9d374 100644 --- a/src/BluetoothManager.cpp +++ b/src/BluetoothManager.cpp @@ -182,10 +182,11 @@ BluetoothManager::BluetoothManager() : event_list() NULL, /* GCancellable */ &error); - if (gdbus_manager == NULL) { - g_printerr("Error getting object manager client: %s", - error->message); - g_error_free(error); + if (gdbus_manager == nullptr) { + std::string error_str("Error getting object manager client: "); + error_str += error->message; + g_error_free(error); + throw std::runtime_error(error_str); } g_thread_new(NULL, init_manager_thread, gdbus_manager); |