mirror of https://github.com/labapart/gattlib
Fix warnings from release build
parent
7d5748cb0d
commit
aacc53c511
|
@ -14,7 +14,9 @@ void gattlib_notification_device_python_callback(const uuid_t* uuid, const uint8
|
|||
int ret;
|
||||
|
||||
ret = gattlib_uuid_to_string(uuid, uuid_str, sizeof(uuid_str));
|
||||
assert(ret == 0);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
d_gstate = PyGILState_Ensure();
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ void get_device_path_from_mac_with_adapter(OrgBluezAdapter1* adapter, const char
|
|||
const char* adapter_path = g_dbus_proxy_get_object_path((GDBusProxy *)ORG_BLUEZ_ADAPTER1_PROXY(adapter));
|
||||
|
||||
// Transform string from 'DA:94:40:95:E0:87' to 'dev_DA_94_40_95_E0_87'
|
||||
strncpy(device_address_str, mac_address, sizeof(device_address_str));
|
||||
strncpy(device_address_str, mac_address, sizeof(device_address_str) - 1);
|
||||
for (int i = 0; i < strlen(device_address_str); i++) {
|
||||
if (device_address_str[i] == ':') {
|
||||
device_address_str[i] = '_';
|
||||
|
@ -111,7 +111,7 @@ void get_device_path_from_mac(const char *adapter_name, const char *mac_address,
|
|||
}
|
||||
|
||||
// Transform string from 'DA:94:40:95:E0:87' to 'dev_DA_94_40_95_E0_87'
|
||||
strncpy(device_address_str, mac_address, sizeof(device_address_str));
|
||||
strncpy(device_address_str, mac_address, sizeof(device_address_str) - 1);
|
||||
for (int i = 0; i < strlen(device_address_str); i++) {
|
||||
if (device_address_str[i] == ':') {
|
||||
device_address_str[i] = '_';
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2016-2021, Olivier Martin <olivier@labapart.org>
|
||||
* Copyright (c) 2016-2024, Olivier Martin <olivier@labapart.org>
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <gio/gunixfdlist.h>
|
||||
|
||||
#include "gattlib_internal.h"
|
||||
|
@ -72,8 +74,12 @@ int gattlib_write_char_by_uuid_stream_open(gatt_connection_t* connection, uuid_t
|
|||
|
||||
int gattlib_write_char_stream_write(gatt_stream_t *stream, const void *buffer, size_t buffer_len)
|
||||
{
|
||||
write((unsigned long)stream, buffer, buffer_len);
|
||||
return GATTLIB_SUCCESS;
|
||||
ssize_t ret = write((unsigned long)stream, buffer, buffer_len);
|
||||
if (ret < 0) {
|
||||
return GATTLIB_ERROR_UNIX_WITH_ERROR(errno);
|
||||
} else {
|
||||
return GATTLIB_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
int gattlib_write_char_stream_close(gatt_stream_t *stream)
|
||||
|
|
|
@ -46,12 +46,15 @@ extern "C" {
|
|||
#define GATTLIB_ERROR_MODULE_MASK 0xF0000000
|
||||
#define GATTLIB_ERROR_DBUS 0x10000000
|
||||
#define GATTLIB_ERROR_BLUEZ 0x20000000
|
||||
#define GATTLIB_ERROR_UNIX 0x30000000
|
||||
#define GATTLIB_ERROR_INTERNAL 0x80000000
|
||||
|
||||
#define GATTLIB_ERROR_DBUS_WITH_ERROR(error) \
|
||||
(GATTLIB_ERROR_DBUS | (error->domain << 8) | (error->code))
|
||||
#define GATTLIB_ERROR_BLUEZ_WITH_ERROR(ret) \
|
||||
(GATTLIB_ERROR_BLUEZ | (ret))
|
||||
#define GATTLIB_ERROR_UNIX_WITH_ERROR(ret) \
|
||||
(GATTLIB_ERROR_UNIX | (ret))
|
||||
//@}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue