dbus: Prevent compiler warning

pull/166/head
Olivier Martin 2020-04-08 15:45:09 +02:00 committed by Olivier Martin
parent 6f3ad714a2
commit 46da1ee50c
4 changed files with 8 additions and 6 deletions

View File

@ -145,6 +145,7 @@ gatt_connection_t *gattlib_connect(void* adapter, const char *dst, unsigned long
if (conn_context == NULL) { if (conn_context == NULL) {
return NULL; return NULL;
} }
conn_context->adapter = gattlib_adapter;
gatt_connection_t* connection = calloc(sizeof(gatt_connection_t), 1); gatt_connection_t* connection = calloc(sizeof(gatt_connection_t), 1);
if (connection == NULL) { if (connection == NULL) {

View File

@ -34,12 +34,12 @@ int gattlib_adapter_open(const char* adapter_name, void** adapter) {
return GATTLIB_INVALID_PARAMETER; return GATTLIB_INVALID_PARAMETER;
} }
if (adapter_name) { if (adapter_name == NULL) {
snprintf(object_path, sizeof(object_path), "/org/bluez/%s", adapter_name); adapter_name = GATTLIB_DEFAULT_ADAPTER;
} else {
strncpy(object_path, "/org/bluez/hci0", sizeof(object_path));
} }
snprintf(object_path, sizeof(object_path), "/org/bluez/%s", adapter_name);
adapter_proxy = org_bluez_adapter1_proxy_new_for_bus_sync( adapter_proxy = org_bluez_adapter1_proxy_new_for_bus_sync(
G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE,
"org.bluez", "org.bluez",

View File

@ -77,8 +77,7 @@ int get_advertisement_data_from_device(OrgBluezDevice1 *bluez_device1,
g_variant_get(values, "ay", &iter); g_variant_get(values, "ay", &iter);
size_t index = 0; size_t index = 0;
while (value = g_variant_iter_next_value(iter)) while ((value = g_variant_iter_next_value(iter)) != NULL) {
{
g_variant_get(value, "y", &(*manufacturer_data)[index++]); g_variant_get(value, "y", &(*manufacturer_data)[index++]);
g_variant_unref(value); g_variant_unref(value);
} }

View File

@ -44,6 +44,8 @@
#include "org-bluez-battery1.h" #include "org-bluez-battery1.h"
#endif #endif
#define GATTLIB_DEFAULT_ADAPTER "hci0"
typedef struct { typedef struct {
struct gattlib_adapter *adapter; struct gattlib_adapter *adapter;