From: Szymon Janc <szymon.janc@tieto.com>
To: <linux-bluetooth@vger.kernel.org>
Cc: Szymon Janc <szymon.janc@tieto.com>
Subject: [RFC 5/7] mgmt: Constify use of bdaddr_t pointer parameters
Date: Thu, 4 Oct 2012 14:06:02 +0200 [thread overview]
Message-ID: <1349352364-5491-6-git-send-email-szymon.janc@tieto.com> (raw)
In-Reply-To: <1349352364-5491-1-git-send-email-szymon.janc@tieto.com>
Mark all input only bdaddr_t pointer parameters as const.
---
plugins/neard.c | 5 +++--
src/adapter.c | 6 +++---
src/adapter.h | 6 +++---
src/mgmt.c | 31 ++++++++++++++++---------------
src/mgmt.h | 26 +++++++++++++-------------
5 files changed, 38 insertions(+), 36 deletions(-)
diff --git a/plugins/neard.c b/plugins/neard.c
index 2fe1785..2da5024 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -216,8 +216,9 @@ static void read_local_complete(struct btd_adapter *adapter, uint8_t *hash,
error("D-Bus send failed");
}
-static void bonding_complete(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- uint8_t status, void *user_data)
+static void bonding_complete(struct btd_adapter *adapter,
+ const bdaddr_t *bdaddr, uint8_t status,
+ void *user_data)
{
DBusMessage *msg = user_data;
DBusMessage *reply;
diff --git a/src/adapter.c b/src/adapter.c
index 4610b85..439046d 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3714,7 +3714,7 @@ int adapter_cancel_bonding(struct btd_adapter *adapter, bdaddr_t *bdaddr)
}
static void check_oob_bonding_complete(struct btd_adapter *adapter,
- bdaddr_t *bdaddr, uint8_t status)
+ const bdaddr_t *bdaddr, uint8_t status)
{
if (!adapter->oob_handler || !adapter->oob_handler->bonding_cb)
return;
@@ -3729,8 +3729,8 @@ static void check_oob_bonding_complete(struct btd_adapter *adapter,
adapter->oob_handler = NULL;
}
-void adapter_bonding_complete(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- uint8_t status)
+void adapter_bonding_complete(struct btd_adapter *adapter,
+ const bdaddr_t *bdaddr, uint8_t status)
{
struct btd_device *device;
char addr[18];
diff --git a/src/adapter.h b/src/adapter.h
index d4fb14b..07c0ad5 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -47,7 +47,7 @@ typedef void (*oob_read_local_cb_t) (struct btd_adapter *adapter,
uint8_t *hash, uint8_t *randomizer,
void *user_data);
typedef void (*oob_bonding_cb_t) (struct btd_adapter *adapter,
- bdaddr_t *bdaddr, uint8_t status,
+ const bdaddr_t *bdaddr, uint8_t status,
void *user_data);
struct oob_handler {
@@ -236,8 +236,8 @@ int adapter_create_bonding(struct btd_adapter *adapter, bdaddr_t *bdaddr,
int adapter_cancel_bonding(struct btd_adapter *adapter, bdaddr_t *bdaddr);
-void adapter_bonding_complete(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- uint8_t status);
+void adapter_bonding_complete(struct btd_adapter *adapter,
+ const bdaddr_t *bdaddr, uint8_t status);
int btd_adapter_read_local_oob_data(struct btd_adapter *adapter);
void adapter_read_local_oob_data_complete(struct btd_adapter *adapter,
diff --git a/src/mgmt.c b/src/mgmt.c
index b689be8..d3f7809 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -432,8 +432,8 @@ static void mgmt_new_settings(int sk, uint16_t index, void *buf, size_t len)
info->current_settings = settings;
}
-static void bonding_complete(struct controller_info *info, bdaddr_t *bdaddr,
- uint8_t status)
+static void bonding_complete(struct controller_info *info,
+ const bdaddr_t *bdaddr, uint8_t status)
{
struct btd_adapter *adapter;
@@ -579,7 +579,7 @@ static void mgmt_connect_failed(int sk, uint16_t index, void *buf, size_t len)
bonding_complete(info, &ev->addr.bdaddr, ev->status);
}
-int mgmt_pincode_reply(int index, bdaddr_t *bdaddr, const char *pin,
+int mgmt_pincode_reply(int index, const bdaddr_t *bdaddr, const char *pin,
size_t pin_len)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_pin_code_reply)];
@@ -660,7 +660,7 @@ static void mgmt_pin_code_request(int sk, uint16_t index, void *buf, size_t len)
}
}
-int mgmt_confirm_reply(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
+int mgmt_confirm_reply(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type,
gboolean success)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_user_confirm_reply)];
@@ -691,7 +691,7 @@ int mgmt_confirm_reply(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
return 0;
}
-int mgmt_passkey_reply(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
+int mgmt_passkey_reply(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type,
uint32_t passkey)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_user_passkey_reply)];
@@ -2130,7 +2130,7 @@ int mgmt_set_fast_connectable(int index, gboolean enable)
return 0;
}
-int mgmt_read_clock(int index, bdaddr_t *bdaddr, int which, int timeout,
+int mgmt_read_clock(int index, const bdaddr_t *bdaddr, int which, int timeout,
uint32_t *clock, uint16_t *accuracy)
{
char addr[18];
@@ -2158,7 +2158,7 @@ int mgmt_read_bdaddr(int index, bdaddr_t *bdaddr)
return 0;
}
-int mgmt_block_device(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type)
+int mgmt_block_device(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_block_device)];
struct mgmt_hdr *hdr = (void *) buf;
@@ -2187,7 +2187,7 @@ int mgmt_block_device(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type)
return 0;
}
-int mgmt_unblock_device(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type)
+int mgmt_unblock_device(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_unblock_device)];
struct mgmt_hdr *hdr = (void *) buf;
@@ -2228,7 +2228,7 @@ int mgmt_get_conn_list(int index, GSList **conns)
return 0;
}
-int mgmt_disconnect(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type)
+int mgmt_disconnect(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_disconnect)];
struct mgmt_hdr *hdr = (void *) buf;
@@ -2252,7 +2252,7 @@ int mgmt_disconnect(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type)
return 0;
}
-int mgmt_unpair_device(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type)
+int mgmt_unpair_device(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_unpair_device)];
struct mgmt_hdr *hdr = (void *) buf;
@@ -2373,7 +2373,8 @@ int mgmt_set_io_capability(int index, uint8_t io_capability)
return 0;
}
-int mgmt_create_bonding(int index, bdaddr_t *bdaddr, uint8_t addr_type, uint8_t io_cap)
+int mgmt_create_bonding(int index, const bdaddr_t *bdaddr, uint8_t addr_type,
+ uint8_t io_cap)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_pair_device)];
struct mgmt_hdr *hdr = (void *) buf;
@@ -2399,7 +2400,7 @@ int mgmt_create_bonding(int index, bdaddr_t *bdaddr, uint8_t addr_type, uint8_t
return 0;
}
-int mgmt_cancel_bonding(int index, bdaddr_t *bdaddr)
+int mgmt_cancel_bonding(int index, const bdaddr_t *bdaddr)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_addr_info)];
struct mgmt_hdr *hdr = (void *) buf;
@@ -2438,7 +2439,7 @@ int mgmt_read_local_oob_data(int index)
return 0;
}
-int mgmt_add_remote_oob_data(int index, bdaddr_t *bdaddr,
+int mgmt_add_remote_oob_data(int index, const bdaddr_t *bdaddr,
uint8_t *hash, uint8_t *randomizer)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_add_remote_oob_data)];
@@ -2467,7 +2468,7 @@ int mgmt_add_remote_oob_data(int index, bdaddr_t *bdaddr,
return 0;
}
-int mgmt_remove_remote_oob_data(int index, bdaddr_t *bdaddr)
+int mgmt_remove_remote_oob_data(int index, const bdaddr_t *bdaddr)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_remove_remote_oob_data)];
struct mgmt_hdr *hdr = (void *) buf;
@@ -2491,7 +2492,7 @@ int mgmt_remove_remote_oob_data(int index, bdaddr_t *bdaddr)
return 0;
}
-int mgmt_confirm_name(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
+int mgmt_confirm_name(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type,
gboolean name_known)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_confirm_name)];
diff --git a/src/mgmt.h b/src/mgmt.h
index 1d25cb0..a2c0497 100644
--- a/src/mgmt.h
+++ b/src/mgmt.h
@@ -36,18 +36,18 @@ int mgmt_start_discovery(int index);
int mgmt_start_le_scanning(int index);
int mgmt_stop_discovery(int index);
-int mgmt_read_clock(int index, bdaddr_t *bdaddr, int which, int timeout,
+int mgmt_read_clock(int index, const bdaddr_t *bdaddr, int which, int timeout,
uint32_t *clock, uint16_t *accuracy);
int mgmt_read_bdaddr(int index, bdaddr_t *bdaddr);
-int mgmt_block_device(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type);
-int mgmt_unblock_device(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type);
+int mgmt_block_device(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type);
+int mgmt_unblock_device(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type);
int mgmt_get_conn_list(int index, GSList **conns);
-int mgmt_disconnect(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type);
+int mgmt_disconnect(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type);
-int mgmt_unpair_device(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type);
+int mgmt_unpair_device(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type);
int mgmt_add_uuid(int index, uuid_t *uuid, uint8_t svc_hint);
int mgmt_remove_uuid(int index, uuid_t *uuid);
@@ -60,24 +60,24 @@ int mgmt_load_ltks(int index, GSList *keys);
int mgmt_set_io_capability(int index, uint8_t io_capability);
-int mgmt_create_bonding(int index, bdaddr_t *bdaddr, uint8_t addr_type,
+int mgmt_create_bonding(int index, const bdaddr_t *bdaddr, uint8_t addr_type,
uint8_t io_cap);
-int mgmt_cancel_bonding(int index, bdaddr_t *bdaddr);
+int mgmt_cancel_bonding(int index, const bdaddr_t *bdaddr);
-int mgmt_pincode_reply(int index, bdaddr_t *bdaddr, const char *pin,
+int mgmt_pincode_reply(int index, const bdaddr_t *bdaddr, const char *pin,
size_t pin_len);
-int mgmt_confirm_reply(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
+int mgmt_confirm_reply(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type,
gboolean success);
-int mgmt_passkey_reply(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
+int mgmt_passkey_reply(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type,
uint32_t passkey);
int mgmt_read_local_oob_data(int index);
-int mgmt_add_remote_oob_data(int index, bdaddr_t *bdaddr,
+int mgmt_add_remote_oob_data(int index, const bdaddr_t *bdaddr,
uint8_t *hash, uint8_t *randomizer);
-int mgmt_remove_remote_oob_data(int index, bdaddr_t *bdaddr);
+int mgmt_remove_remote_oob_data(int index, const bdaddr_t *bdaddr);
-int mgmt_confirm_name(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
+int mgmt_confirm_name(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type,
gboolean name_known);
int mgmt_ssp_enabled(int index);
--
1.7.9.5
next prev parent reply other threads:[~2012-10-04 12:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-04 12:05 [RFC 0/7] adapter and device bdaddr_t getters Szymon Janc
2012-10-04 12:05 ` [RFC 1/7] adapter: Convert adapter_get_address into simple getter Szymon Janc
2012-10-04 12:05 ` [RFC 2/7] storage: Constify bdaddr_t pointers parameters Szymon Janc
2012-10-04 12:06 ` [RFC 3/7] adapter: Constify pointer returned by adapter_get_address Szymon Janc
2012-10-04 12:06 ` [RFC 4/7] device: Convert device_get_address into simple getter Szymon Janc
2012-10-04 12:06 ` Szymon Janc [this message]
2012-10-04 12:06 ` [RFC 6/7] adapter: Constify use of bdaddr_t pointer parameters Szymon Janc
2012-10-04 12:06 ` [RFC 7/7] device: Make device_get_address return const pointer Szymon Janc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1349352364-5491-6-git-send-email-szymon.janc@tieto.com \
--to=szymon.janc@tieto.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox