You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2017/05/18 23:59:20 UTC
[8/9] incubator-mynewt-core git commit: MYNEWT-754 BLE Host - Add
some missing consts.
MYNEWT-754 BLE Host - Add some missing consts.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/507773fd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/507773fd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/507773fd
Branch: refs/heads/master
Commit: 507773fdcd1aff62db51fe1f8afdf7b0014e4099
Parents: 7ad9882
Author: Christopher Collins <cc...@apache.org>
Authored: Thu May 11 15:40:59 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu May 11 18:04:41 2017 -0700
----------------------------------------------------------------------
net/nimble/host/include/host/ble_store.h | 36 +++++++++----------
net/nimble/host/src/ble_hs_pvcy.c | 5 +--
net/nimble/host/src/ble_hs_pvcy_priv.h | 5 +--
net/nimble/host/src/ble_store.c | 33 ++++++++---------
.../store/ram/include/store/ram/ble_store_ram.h | 6 ++--
net/nimble/host/store/ram/src/ble_store_ram.c | 38 ++++++++++----------
.../host/test/src/ble_gatts_notify_test.c | 4 +--
net/nimble/host/test/src/ble_hs_test_util.c | 6 ++--
8 files changed, 68 insertions(+), 65 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/507773fd/net/nimble/host/include/host/ble_store.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_store.h b/net/nimble/host/include/host/ble_store.h
index ec39ea8..ec58ea3 100644
--- a/net/nimble/host/include/host/ble_store.h
+++ b/net/nimble/host/include/host/ble_store.h
@@ -148,7 +148,7 @@ union ble_store_value {
* BLE_HS_ENOENT if no matching object was found;
* Other nonzero on error.
*/
-typedef int ble_store_read_fn(int obj_type, union ble_store_key *key,
+typedef int ble_store_read_fn(int obj_type, const union ble_store_key *key,
union ble_store_value *dst);
/**
@@ -164,7 +164,7 @@ typedef int ble_store_read_fn(int obj_type, union ble_store_key *key,
* @return 0 if the object was successfully written;
* Other nonzero on error.
*/
-typedef int ble_store_write_fn(int obj_type, union ble_store_value *val);
+typedef int ble_store_write_fn(int obj_type, const union ble_store_value *val);
/**
* Searches the store for the first object matching the specified criteria. If
@@ -179,35 +179,35 @@ typedef int ble_store_write_fn(int obj_type, union ble_store_value *val);
* BLE_HS_ENOENT if no matching object was found;
* Other nonzero on error.
*/
-typedef int ble_store_delete_fn(int obj_type, union ble_store_key *key);
+typedef int ble_store_delete_fn(int obj_type, const union ble_store_key *key);
-int ble_store_read(int obj_type, union ble_store_key *key,
+int ble_store_read(int obj_type, const union ble_store_key *key,
union ble_store_value *val);
-int ble_store_write(int obj_type, union ble_store_value *val);
-int ble_store_delete(int obj_type, union ble_store_key *key);
+int ble_store_write(int obj_type, const union ble_store_value *val);
+int ble_store_delete(int obj_type, const union ble_store_key *key);
-int ble_store_read_our_sec(struct ble_store_key_sec *key_sec,
+int ble_store_read_our_sec(const struct ble_store_key_sec *key_sec,
struct ble_store_value_sec *value_sec);
-int ble_store_write_our_sec(struct ble_store_value_sec *value_sec);
-int ble_store_delete_our_sec(struct ble_store_key_sec *key_sec);
-int ble_store_read_peer_sec(struct ble_store_key_sec *key_sec,
+int ble_store_write_our_sec(const struct ble_store_value_sec *value_sec);
+int ble_store_delete_our_sec(const struct ble_store_key_sec *key_sec);
+int ble_store_read_peer_sec(const struct ble_store_key_sec *key_sec,
struct ble_store_value_sec *value_sec);
-int ble_store_write_peer_sec(struct ble_store_value_sec *value_sec);
-int ble_store_delete_peer_sec(struct ble_store_key_sec *key_sec);
+int ble_store_write_peer_sec(const struct ble_store_value_sec *value_sec);
+int ble_store_delete_peer_sec(const struct ble_store_key_sec *key_sec);
-int ble_store_read_cccd(struct ble_store_key_cccd *key,
+int ble_store_read_cccd(const struct ble_store_key_cccd *key,
struct ble_store_value_cccd *out_value);
-int ble_store_write_cccd(struct ble_store_value_cccd *value);
-int ble_store_delete_cccd(struct ble_store_key_cccd *key);
+int ble_store_write_cccd(const struct ble_store_value_cccd *value);
+int ble_store_delete_cccd(const struct ble_store_key_cccd *key);
void ble_store_key_from_value_sec(struct ble_store_key_sec *out_key,
- struct ble_store_value_sec *value);
+ const struct ble_store_value_sec *value);
void ble_store_key_from_value_cccd(struct ble_store_key_cccd *out_key,
- struct ble_store_value_cccd *value);
+ const struct ble_store_value_cccd *value);
void ble_store_key_from_value(int obj_type,
union ble_store_key *out_key,
- union ble_store_value *value);
+ const union ble_store_value *value);
typedef int ble_store_iterator_fn(int obj_type,
union ble_store_value *val,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/507773fd/net/nimble/host/src/ble_hs_pvcy.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_pvcy.c b/net/nimble/host/src/ble_hs_pvcy.c
index 3a6d974..b41c898 100644
--- a/net/nimble/host/src/ble_hs_pvcy.c
+++ b/net/nimble/host/src/ble_hs_pvcy.c
@@ -66,7 +66,7 @@ ble_hs_pvcy_set_resolve_enabled(int enable)
}
int
-ble_hs_pvcy_remove_entry(uint8_t addr_type, uint8_t *addr)
+ble_hs_pvcy_remove_entry(uint8_t addr_type, const uint8_t *addr)
{
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_RMV_FROM_RESOLV_LIST_LEN];
int rc;
@@ -105,7 +105,8 @@ ble_hs_pvcy_clear_entries(void)
}
int
-ble_hs_pvcy_add_entry(uint8_t *addr, uint8_t addr_type, uint8_t *irk)
+ble_hs_pvcy_add_entry(const uint8_t *addr, uint8_t addr_type,
+ const uint8_t *irk)
{
struct hci_add_dev_to_resolving_list add;
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_ADD_TO_RESOLV_LIST_LEN];
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/507773fd/net/nimble/host/src/ble_hs_pvcy_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_pvcy_priv.h b/net/nimble/host/src/ble_hs_pvcy_priv.h
index 62689d3..7925ca2 100644
--- a/net/nimble/host/src/ble_hs_pvcy_priv.h
+++ b/net/nimble/host/src/ble_hs_pvcy_priv.h
@@ -28,8 +28,9 @@ extern "C" {
int ble_hs_pvcy_set_our_irk(const uint8_t *irk);
int ble_hs_pvcy_our_irk(const uint8_t **out_irk);
-int ble_hs_pvcy_remove_entry(uint8_t addr_type, uint8_t *addr);
-int ble_hs_pvcy_add_entry(uint8_t *addr, uint8_t addrtype, uint8_t *irk);
+int ble_hs_pvcy_remove_entry(uint8_t addr_type, const uint8_t *addr);
+int ble_hs_pvcy_add_entry(const uint8_t *addr, uint8_t addrtype,
+ const uint8_t *irk);
int ble_hs_pvcy_ensure_started(void);
#ifdef __cplusplus
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/507773fd/net/nimble/host/src/ble_store.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_store.c b/net/nimble/host/src/ble_store.c
index 88697ac..2132321 100644
--- a/net/nimble/host/src/ble_store.c
+++ b/net/nimble/host/src/ble_store.c
@@ -23,7 +23,7 @@
#include "ble_hs_priv.h"
int
-ble_store_read(int obj_type, union ble_store_key *key,
+ble_store_read(int obj_type, const union ble_store_key *key,
union ble_store_value *val)
{
int rc;
@@ -38,7 +38,7 @@ ble_store_read(int obj_type, union ble_store_key *key,
}
int
-ble_store_write(int obj_type, union ble_store_value *val)
+ble_store_write(int obj_type, const union ble_store_value *val)
{
int rc;
@@ -52,7 +52,7 @@ ble_store_write(int obj_type, union ble_store_value *val)
}
int
-ble_store_delete(int obj_type, union ble_store_key *key)
+ble_store_delete(int obj_type, const union ble_store_key *key)
{
int rc;
@@ -66,7 +66,7 @@ ble_store_delete(int obj_type, union ble_store_key *key)
}
int
-ble_store_read_our_sec(struct ble_store_key_sec *key_sec,
+ble_store_read_our_sec(const struct ble_store_key_sec *key_sec,
struct ble_store_value_sec *value_sec)
{
union ble_store_value *store_value;
@@ -84,7 +84,8 @@ ble_store_read_our_sec(struct ble_store_key_sec *key_sec,
}
static int
-ble_store_persist_sec(int obj_type, struct ble_store_value_sec *value_sec)
+ble_store_persist_sec(int obj_type,
+ const struct ble_store_value_sec *value_sec)
{
union ble_store_value *store_value;
int rc;
@@ -101,7 +102,7 @@ ble_store_persist_sec(int obj_type, struct ble_store_value_sec *value_sec)
}
int
-ble_store_write_our_sec(struct ble_store_value_sec *value_sec)
+ble_store_write_our_sec(const struct ble_store_value_sec *value_sec)
{
int rc;
@@ -110,7 +111,7 @@ ble_store_write_our_sec(struct ble_store_value_sec *value_sec)
}
int
-ble_store_delete_our_sec(struct ble_store_key_sec *key_sec)
+ble_store_delete_our_sec(const struct ble_store_key_sec *key_sec)
{
union ble_store_key *store_key;
int rc;
@@ -121,7 +122,7 @@ ble_store_delete_our_sec(struct ble_store_key_sec *key_sec)
}
int
-ble_store_delete_peer_sec(struct ble_store_key_sec *key_sec)
+ble_store_delete_peer_sec(const struct ble_store_key_sec *key_sec)
{
union ble_store_key *store_key;
int rc;
@@ -132,7 +133,7 @@ ble_store_delete_peer_sec(struct ble_store_key_sec *key_sec)
}
int
-ble_store_read_peer_sec(struct ble_store_key_sec *key_sec,
+ble_store_read_peer_sec(const struct ble_store_key_sec *key_sec,
struct ble_store_value_sec *value_sec)
{
union ble_store_value *store_value;
@@ -154,7 +155,7 @@ ble_store_read_peer_sec(struct ble_store_key_sec *key_sec,
}
int
-ble_store_write_peer_sec(struct ble_store_value_sec *value_sec)
+ble_store_write_peer_sec(const struct ble_store_value_sec *value_sec)
{
int rc;
@@ -180,7 +181,7 @@ ble_store_write_peer_sec(struct ble_store_value_sec *value_sec)
}
int
-ble_store_read_cccd(struct ble_store_key_cccd *key,
+ble_store_read_cccd(const struct ble_store_key_cccd *key,
struct ble_store_value_cccd *out_value)
{
union ble_store_value *store_value;
@@ -194,7 +195,7 @@ ble_store_read_cccd(struct ble_store_key_cccd *key,
}
int
-ble_store_write_cccd(struct ble_store_value_cccd *value)
+ble_store_write_cccd(const struct ble_store_value_cccd *value)
{
union ble_store_value *store_value;
int rc;
@@ -205,7 +206,7 @@ ble_store_write_cccd(struct ble_store_value_cccd *value)
}
int
-ble_store_delete_cccd(struct ble_store_key_cccd *key)
+ble_store_delete_cccd(const struct ble_store_key_cccd *key)
{
union ble_store_key *store_key;
int rc;
@@ -217,7 +218,7 @@ ble_store_delete_cccd(struct ble_store_key_cccd *key)
void
ble_store_key_from_value_cccd(struct ble_store_key_cccd *out_key,
- struct ble_store_value_cccd *value)
+ const struct ble_store_value_cccd *value)
{
out_key->peer_addr = value->peer_addr;
out_key->chr_val_handle = value->chr_val_handle;
@@ -226,7 +227,7 @@ ble_store_key_from_value_cccd(struct ble_store_key_cccd *out_key,
void
ble_store_key_from_value_sec(struct ble_store_key_sec *out_key,
- struct ble_store_value_sec *value)
+ const struct ble_store_value_sec *value)
{
out_key->peer_addr = value->peer_addr;
@@ -239,7 +240,7 @@ ble_store_key_from_value_sec(struct ble_store_key_sec *out_key,
void
ble_store_key_from_value(int obj_type,
union ble_store_key *out_key,
- union ble_store_value *value)
+ const union ble_store_value *value)
{
switch (obj_type) {
case BLE_STORE_OBJ_TYPE_OUR_SEC:
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/507773fd/net/nimble/host/store/ram/include/store/ram/ble_store_ram.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/store/ram/include/store/ram/ble_store_ram.h b/net/nimble/host/store/ram/include/store/ram/ble_store_ram.h
index fc8375c..842fb5f 100644
--- a/net/nimble/host/store/ram/include/store/ram/ble_store_ram.h
+++ b/net/nimble/host/store/ram/include/store/ram/ble_store_ram.h
@@ -27,10 +27,10 @@ extern "C" {
union ble_store_key;
union ble_store_value;
-int ble_store_ram_read(int obj_type, union ble_store_key *key,
+int ble_store_ram_read(int obj_type, const union ble_store_key *key,
union ble_store_value *value);
-int ble_store_ram_write(int obj_type, union ble_store_value *val);
-int ble_store_ram_delete(int obj_type, union ble_store_key *key);
+int ble_store_ram_write(int obj_type, const union ble_store_value *val);
+int ble_store_ram_delete(int obj_type, const union ble_store_key *key);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/507773fd/net/nimble/host/store/ram/src/ble_store_ram.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/store/ram/src/ble_store_ram.c b/net/nimble/host/store/ram/src/ble_store_ram.c
index 387112c..058f08a 100644
--- a/net/nimble/host/store/ram/src/ble_store_ram.c
+++ b/net/nimble/host/store/ram/src/ble_store_ram.c
@@ -48,7 +48,7 @@ static int ble_store_ram_num_cccds;
*****************************************************************************/
static void
-ble_store_ram_print_value_sec(struct ble_store_value_sec *sec)
+ble_store_ram_print_value_sec(const struct ble_store_value_sec *sec)
{
if (sec->ltk_present) {
BLE_HS_LOG(DEBUG, "ediv=%u rand=%llu authenticated=%d ltk=",
@@ -71,7 +71,7 @@ ble_store_ram_print_value_sec(struct ble_store_value_sec *sec)
}
static void
-ble_store_ram_print_key_sec(struct ble_store_key_sec *key_sec)
+ble_store_ram_print_key_sec(const struct ble_store_key_sec *key_sec)
{
if (ble_addr_cmp(&key_sec->peer_addr, BLE_ADDR_ANY)) {
BLE_HS_LOG(DEBUG, "peer_addr_type=%d peer_addr=",
@@ -86,11 +86,11 @@ ble_store_ram_print_key_sec(struct ble_store_key_sec *key_sec)
}
static int
-ble_store_ram_find_sec(struct ble_store_key_sec *key_sec,
- struct ble_store_value_sec *value_secs,
+ble_store_ram_find_sec(const struct ble_store_key_sec *key_sec,
+ const struct ble_store_value_sec *value_secs,
int num_value_secs)
{
- struct ble_store_value_sec *cur;
+ const struct ble_store_value_sec *cur;
int skipped;
int i;
@@ -127,7 +127,7 @@ ble_store_ram_find_sec(struct ble_store_key_sec *key_sec,
}
static int
-ble_store_ram_read_our_sec(struct ble_store_key_sec *key_sec,
+ble_store_ram_read_our_sec(const struct ble_store_key_sec *key_sec,
struct ble_store_value_sec *value_sec)
{
int idx;
@@ -143,7 +143,7 @@ ble_store_ram_read_our_sec(struct ble_store_key_sec *key_sec,
}
static int
-ble_store_ram_write_our_sec(struct ble_store_value_sec *value_sec)
+ble_store_ram_write_our_sec(const struct ble_store_value_sec *value_sec)
{
struct ble_store_key_sec key_sec;
int idx;
@@ -191,7 +191,7 @@ ble_store_ram_delete_obj(void *values, int value_size, int idx,
}
static int
-ble_store_ram_delete_sec(struct ble_store_key_sec *key_sec,
+ble_store_ram_delete_sec(const struct ble_store_key_sec *key_sec,
struct ble_store_value_sec *value_secs,
int *num_value_secs)
{
@@ -213,7 +213,7 @@ ble_store_ram_delete_sec(struct ble_store_key_sec *key_sec,
}
static int
-ble_store_ram_delete_our_sec(struct ble_store_key_sec *key_sec)
+ble_store_ram_delete_our_sec(const struct ble_store_key_sec *key_sec)
{
int rc;
@@ -227,7 +227,7 @@ ble_store_ram_delete_our_sec(struct ble_store_key_sec *key_sec)
}
static int
-ble_store_ram_delete_peer_sec(struct ble_store_key_sec *key_sec)
+ble_store_ram_delete_peer_sec(const struct ble_store_key_sec *key_sec)
{
int rc;
@@ -241,7 +241,7 @@ ble_store_ram_delete_peer_sec(struct ble_store_key_sec *key_sec)
}
static int
-ble_store_ram_read_peer_sec(struct ble_store_key_sec *key_sec,
+ble_store_ram_read_peer_sec(const struct ble_store_key_sec *key_sec,
struct ble_store_value_sec *value_sec)
{
int idx;
@@ -257,7 +257,7 @@ ble_store_ram_read_peer_sec(struct ble_store_key_sec *key_sec,
}
static int
-ble_store_ram_write_peer_sec(struct ble_store_value_sec *value_sec)
+ble_store_ram_write_peer_sec(const struct ble_store_value_sec *value_sec)
{
struct ble_store_key_sec key_sec;
int idx;
@@ -288,7 +288,7 @@ ble_store_ram_write_peer_sec(struct ble_store_value_sec *value_sec)
*****************************************************************************/
static int
-ble_store_ram_find_cccd(struct ble_store_key_cccd *key)
+ble_store_ram_find_cccd(const struct ble_store_key_cccd *key)
{
struct ble_store_value_cccd *cccd;
int skipped;
@@ -322,8 +322,8 @@ ble_store_ram_find_cccd(struct ble_store_key_cccd *key)
}
static int
-ble_store_ram_read_cccd(struct ble_store_key_cccd *key_cccd,
- struct ble_store_value_cccd *value_cccd)
+ble_store_ram_read_cccd(const struct ble_store_key_cccd *key_cccd,
+ struct ble_store_value_cccd *value_cccd)
{
int idx;
@@ -337,7 +337,7 @@ ble_store_ram_read_cccd(struct ble_store_key_cccd *key_cccd,
}
static int
-ble_store_ram_write_cccd(struct ble_store_value_cccd *value_cccd)
+ble_store_ram_write_cccd(const struct ble_store_value_cccd *value_cccd)
{
struct ble_store_key_cccd key_cccd;
int idx;
@@ -369,7 +369,7 @@ ble_store_ram_write_cccd(struct ble_store_value_cccd *value_cccd)
* @return 0 if a key was found; else BLE_HS_ENOENT.
*/
int
-ble_store_ram_read(int obj_type, union ble_store_key *key,
+ble_store_ram_read(int obj_type, const union ble_store_key *key,
union ble_store_value *value)
{
int rc;
@@ -413,7 +413,7 @@ ble_store_ram_read(int obj_type, union ble_store_key *key,
* full.
*/
int
-ble_store_ram_write(int obj_type, union ble_store_value *val)
+ble_store_ram_write(int obj_type, const union ble_store_value *val)
{
int rc;
@@ -436,7 +436,7 @@ ble_store_ram_write(int obj_type, union ble_store_value *val)
}
int
-ble_store_ram_delete(int obj_type, union ble_store_key *key)
+ble_store_ram_delete(int obj_type, const union ble_store_key *key)
{
int rc;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/507773fd/net/nimble/host/test/src/ble_gatts_notify_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_gatts_notify_test.c b/net/nimble/host/test/src/ble_gatts_notify_test.c
index 357d250..96bc081 100644
--- a/net/nimble/host/test/src/ble_gatts_notify_test.c
+++ b/net/nimble/host/test/src/ble_gatts_notify_test.c
@@ -74,9 +74,9 @@ ble_gatts_notify_test_events[BLE_GATTS_NOTIFY_TEST_MAX_EVENTS];
static int ble_gatts_notify_test_num_events;
-typedef int ble_store_write_fn(int obj_type, union ble_store_value *val);
+typedef int ble_store_write_fn(int obj_type, const union ble_store_value *val);
-typedef int ble_store_delete_fn(int obj_type, union ble_store_key *key);
+typedef int ble_store_delete_fn(int obj_type, const union ble_store_key *key);
static int
ble_gatts_notify_test_util_gap_event(struct ble_gap_event *event, void *arg)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/507773fd/net/nimble/host/test/src/ble_hs_test_util.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_hs_test_util.c b/net/nimble/host/test/src/ble_hs_test_util.c
index 7c72d5d..7fcfd8d 100644
--- a/net/nimble/host/test/src/ble_hs_test_util.c
+++ b/net/nimble/host/test/src/ble_hs_test_util.c
@@ -2320,7 +2320,7 @@ ble_hs_test_util_num_peer_secs(void)
}
static int
-ble_hs_test_util_store_read(int obj_type, union ble_store_key *key,
+ble_hs_test_util_store_read(int obj_type, const union ble_store_key *key,
union ble_store_value *value)
{
int rc;
@@ -2335,7 +2335,7 @@ ble_hs_test_util_store_read(int obj_type, union ble_store_key *key,
}
static int
-ble_hs_test_util_store_write(int obj_type, union ble_store_value *value)
+ble_hs_test_util_store_write(int obj_type, const union ble_store_value *value)
{
int rc;
@@ -2348,7 +2348,7 @@ ble_hs_test_util_store_write(int obj_type, union ble_store_value *value)
}
static int
-ble_hs_test_util_store_delete(int obj_type, union ble_store_key *key)
+ble_hs_test_util_store_delete(int obj_type, const union ble_store_key *key)
{
int rc;