summaryrefslogtreecommitdiffstats
path: root/src/tinyb
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-10-17 01:50:38 +0200
committerSven Gothel <[email protected]>2020-10-17 01:50:38 +0200
commit8461947da0ff33dca53eb78bbe99e72c8177a428 (patch)
treed3226ba3646470e61235c905d1a9aa452ad4c488 /src/tinyb
parent09839e0e62ed81cd2c1ac5421d0acc0a85b09d5e (diff)
src/tinyb/Bluetooth*cpp: Compile clean w/ full Warnings
Diffstat (limited to 'src/tinyb')
-rw-r--r--src/tinyb/BluetoothAdapter.cpp2
-rw-r--r--src/tinyb/BluetoothDevice.cpp2
-rw-r--r--src/tinyb/BluetoothGattCharacteristic.cpp3
-rw-r--r--src/tinyb/BluetoothGattDescriptor.cpp3
-rw-r--r--src/tinyb/BluetoothManager.cpp9
-rw-r--r--src/tinyb/BluetoothUUID.cpp35
6 files changed, 37 insertions, 17 deletions
diff --git a/src/tinyb/BluetoothAdapter.cpp b/src/tinyb/BluetoothAdapter.cpp
index eab4eacd..c09e9c1f 100644
--- a/src/tinyb/BluetoothAdapter.cpp
+++ b/src/tinyb/BluetoothAdapter.cpp
@@ -33,6 +33,8 @@
using namespace tinyb;
void BluetoothNotificationHandler::on_properties_changed_adapter(GDBusProxy *proxy, GVariant *changed_properties, GStrv invalidated_properties, gpointer userdata) {
+ (void) proxy;
+ (void) invalidated_properties;
auto c = static_cast<BluetoothAdapter*>(userdata);
diff --git a/src/tinyb/BluetoothDevice.cpp b/src/tinyb/BluetoothDevice.cpp
index 97538cd4..bee0205e 100644
--- a/src/tinyb/BluetoothDevice.cpp
+++ b/src/tinyb/BluetoothDevice.cpp
@@ -33,6 +33,8 @@
using namespace tinyb;
void BluetoothNotificationHandler::on_properties_changed_device(GDBusProxy *proxy, GVariant *changed_properties, GStrv invalidated_properties, gpointer userdata) {
+ (void) proxy;
+ (void) invalidated_properties;
auto c = static_cast<BluetoothDevice*>(userdata);
diff --git a/src/tinyb/BluetoothGattCharacteristic.cpp b/src/tinyb/BluetoothGattCharacteristic.cpp
index 30914e9e..33c14fcd 100644
--- a/src/tinyb/BluetoothGattCharacteristic.cpp
+++ b/src/tinyb/BluetoothGattCharacteristic.cpp
@@ -33,7 +33,8 @@
using namespace tinyb;
void BluetoothNotificationHandler::on_properties_changed_characteristic(GDBusProxy *proxy, GVariant *changed_properties, GStrv invalidated_properties, gpointer userdata) {
-
+ (void) proxy;
+ (void) invalidated_properties;
auto c = static_cast<BluetoothGattCharacteristic*>(userdata);
if(g_variant_n_children(changed_properties) > 0) {
diff --git a/src/tinyb/BluetoothGattDescriptor.cpp b/src/tinyb/BluetoothGattDescriptor.cpp
index 72acdd37..3732d37f 100644
--- a/src/tinyb/BluetoothGattDescriptor.cpp
+++ b/src/tinyb/BluetoothGattDescriptor.cpp
@@ -32,7 +32,8 @@
using namespace tinyb;
void BluetoothNotificationHandler::on_properties_changed_descriptor(GDBusProxy *proxy, GVariant *changed_properties, GStrv invalidated_properties, gpointer userdata) {
-
+ (void) proxy;
+ (void) invalidated_properties;
auto c = static_cast<BluetoothGattDescriptor*>(userdata);
if(g_variant_n_children(changed_properties) > 0) {
diff --git a/src/tinyb/BluetoothManager.cpp b/src/tinyb/BluetoothManager.cpp
index b6868d09..71a42bc9 100644
--- a/src/tinyb/BluetoothManager.cpp
+++ b/src/tinyb/BluetoothManager.cpp
@@ -41,6 +41,9 @@ class tinyb::BluetoothEventManager {
public:
static void on_interface_added (GDBusObject *object,
GDBusInterface *interface, gpointer user_data) {
+ (void) object;
+ (void) user_data;
+
GDBusInterfaceInfo *info = g_dbus_interface_get_info(interface);
BluetoothType type = BluetoothType::NONE;
BluetoothManager *manager = BluetoothManager::get_bluetooth_manager();
@@ -89,6 +92,8 @@ public:
static void on_object_added (GDBusObjectManager *manager,
GDBusObject *object, gpointer user_data) {
+ (void) manager;
+
GList *l, *interfaces = g_dbus_object_get_interfaces(object);
for(l = interfaces; l != NULL; l = l->next)
@@ -198,6 +203,10 @@ std::weak_ptr<BluetoothEvent> BluetoothManager::find(BluetoothType type,
BluetoothCallback cb, bool execute_once,
std::chrono::milliseconds timeout)
{
+ (void)cb;
+ (void)execute_once;
+ (void)timeout;
+
std::shared_ptr<BluetoothEvent> event(new BluetoothEvent(type, name,
identifier, parent));
add_event(event);
diff --git a/src/tinyb/BluetoothUUID.cpp b/src/tinyb/BluetoothUUID.cpp
index ce8124a5..6d25e19e 100644
--- a/src/tinyb/BluetoothUUID.cpp
+++ b/src/tinyb/BluetoothUUID.cpp
@@ -1,4 +1,6 @@
#include "BluetoothUUID.hpp"
+
+#include <cinttypes>
#include <cstring>
#include <iostream>
@@ -14,8 +16,9 @@ BluetoothUUID::BluetoothUUID(const char str[]) {
const char *err_msg = "UUID does not have a valid format";
if (len == 4 || len == 8) {
- /* 16bit or 32bit UUID: number + base UUID */
- uuid[0] = strtoul(str, NULL, 16) << 32 | 0x00001000ULL;
+ /* 16bit or 32bit UUID: number + base UUID */
+ const uint64_t strval = strtoul(str, NULL, 16);
+ uuid[0] = strval << 32 | 0x00001000ULL;
uuid[1] = 0x800000805f9b34fbULL;
} else if (len == 36) {
/* 128bit UUID */
@@ -24,7 +27,8 @@ BluetoothUUID::BluetoothUUID(const char str[]) {
if (u[8] == '-') {
u[8] = ' ';
- uuid[0] = strtoul(u + 0, NULL, 16) << 32;
+ const uint64_t uval = strtoul(u + 0, NULL, 16);
+ uuid[0] = uval << 32;
} else {
throw std::invalid_argument(err_msg);
}
@@ -39,7 +43,8 @@ BluetoothUUID::BluetoothUUID(const char str[]) {
if (u[23] == '-') {
u[23] = ' ';
- uuid[1] = strtoul(u + 19, NULL, 16) << 48;
+ const uint64_t uval = strtoul(u + 19, NULL, 16);
+ uuid[1] = uval << 48;
} else throw std::invalid_argument(err_msg);
uuid[1] = uuid[1] | strtoul(u + 24, NULL, 16);
@@ -51,24 +56,24 @@ BluetoothUUID::BluetoothUUID(const std::string &str) : BluetoothUUID(str.c_str()
std::string BluetoothUUID::get_string()
{
char u[37];
- snprintf(u, 37, "%08lx-%04llx-%04llx-%04lx-%012llx",
- (uuid[0] >> 32),
- ((uuid[0] >> 16) & 0xFFFFULL),
- (uuid[0] & 0xFFFFULL),
- (uuid[1] >> 48),
- (uuid[1] & ~(0xFFFFULL << 48)));
+ snprintf(u, 37, "%08" PRIx64 "-%04" PRIx64 "-%04" PRIx64 "-%04" PRIx64 "-%012" PRIx64,
+ (uint64_t)(uuid[0] >> 32),
+ (uint64_t)((uuid[0] >> 16) & 0xFFFFULL),
+ (uint64_t)(uuid[0] & 0xFFFFULL),
+ (uint64_t)(uuid[1] >> 48),
+ (uint64_t)(uuid[1] & ~(0xFFFFULL << 48)));
return std::string(u);
}
std::string BluetoothUUID::get_short_string()
{
- char u[9];
+ char u[12];
if (is_short()) {
uint32_t suuid = get_short();
- if (suuid & 0xFFFF == suuid)
- snprintf(u, 9, "%04dx", suuid);
+ if ( ( suuid & 0xFFFF ) == suuid )
+ snprintf(u, sizeof(u), "%04ux", suuid);
else
- snprintf(u, 9, "%08dx", suuid);
+ snprintf(u, sizeof(u), "%08ux", suuid);
return std::string(u);
} else {
return get_string();
@@ -83,7 +88,7 @@ uint32_t BluetoothUUID::get_short() {
bool BluetoothUUID::is_short()
{
- if (uuid[1] == 0x800000805f9b34fbULL && uuid[0] & 0xffffffffULL == 0x00001000ULL)
+ if ( ( uuid[1] == 0x800000805f9b34fbULL ) && uuid[0] & ( 0xffffffffULL == 0x00001000ULL ) )
return true;
return false;
}