Skip to content

Commit

Permalink
Bluetooth: GATT: Fix const'ness of characteristic descriptor data
Browse files Browse the repository at this point in the history
None of the data for the CEP, CUD and CPF descriptors needs to be
modified by the stack at runtime. Make it possible to pass constant
data to the descriptor macros, and make sure the descriptor handlers
cast the data back to be a constant.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
  • Loading branch information
jhedberg committed Sep 18, 2018
1 parent 62d7a7a commit 366378f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions include/bluetooth/gatt.h
Expand Up @@ -582,7 +582,7 @@ ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn,
*/
#define BT_GATT_CEP(_value) \
BT_GATT_DESCRIPTOR(BT_UUID_GATT_CEP, BT_GATT_PERM_READ, \
bt_gatt_attr_read_cep, NULL, _value)
bt_gatt_attr_read_cep, NULL, (void *)_value)

/** @brief Read Characteristic User Description Descriptor Attribute helper
*
Expand Down Expand Up @@ -613,7 +613,7 @@ ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn,
*/
#define BT_GATT_CUD(_value, _perm) \
BT_GATT_DESCRIPTOR(BT_UUID_GATT_CUD, _perm, bt_gatt_attr_read_cud, \
NULL, _value)
NULL, (void *)_value)

/** @brief Read Characteristic Presentation format Descriptor Attribute helper
*
Expand Down Expand Up @@ -643,7 +643,7 @@ ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn,
*/
#define BT_GATT_CPF(_value) \
BT_GATT_DESCRIPTOR(BT_UUID_GATT_CPF, BT_GATT_PERM_READ, \
bt_gatt_attr_read_cpf, NULL, (void * const)_value)
bt_gatt_attr_read_cpf, NULL, (void *)_value)

/** @def BT_GATT_DESCRIPTOR
* @brief Descriptor Declaration Macro.
Expand Down
6 changes: 3 additions & 3 deletions subsys/bluetooth/host/gatt.c
Expand Up @@ -651,7 +651,7 @@ ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
struct bt_gatt_cep *value = attr->user_data;
const struct bt_gatt_cep *value = attr->user_data;
u16_t props = sys_cpu_to_le16(value->properties);

return bt_gatt_attr_read(conn, attr, buf, len, offset, &props,
Expand All @@ -662,7 +662,7 @@ ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
char *value = attr->user_data;
const char *value = attr->user_data;

return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
strlen(value));
Expand All @@ -672,7 +672,7 @@ ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
struct bt_gatt_cpf *value = attr->user_data;
const struct bt_gatt_cpf *value = attr->user_data;

return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(*value));
Expand Down

0 comments on commit 366378f

Please sign in to comment.