bluetooth: ots: Enable testing with assert
Fix compilation and logic issues to allow testing OTS functionality with assert enabled. The compilation fixes are simple and do not require an explanation. The assertion in bt_ots_dir_list_init was logically reversed. Its purpose is to ensure the directory list is not already initialized and as such should assert that the dir_list is not set (i.e. is NULL). Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
This commit is contained in:
parent
c3ca5ada1a
commit
190848177e
2 changed files with 5 additions and 4 deletions
|
|
@ -8,3 +8,4 @@ CONFIG_BT_OTS_OACP_WRITE_SUPPORT=y
|
|||
CONFIG_BT_OTS_OACP_PATCH_SUPPORT=y
|
||||
|
||||
CONFIG_LOG=y
|
||||
CONFIG_ASSERT=y
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ static void dir_list_object_encode(struct bt_gatt_ots_object *obj,
|
|||
/* Name length */
|
||||
obj_name_len = strlen(obj->metadata.name);
|
||||
__ASSERT(obj_name_len > 0 && obj_name_len <= CONFIG_BT_OTS_OBJ_MAX_NAME_LEN,
|
||||
"Dir list object len is incorrect %zu", len);
|
||||
"Dir list object len is incorrect %zu", obj_name_len);
|
||||
net_buf_simple_add_u8(net_buf, obj_name_len);
|
||||
|
||||
/* Name */
|
||||
|
|
@ -170,7 +170,7 @@ static void dir_list_encode(struct bt_ots_dir_list *dir_list, void *obj_manager)
|
|||
|
||||
err = bt_gatt_ots_obj_manager_first_obj_get(obj_manager, &obj);
|
||||
|
||||
__ASSERT(err == 0 && first_obj == dir_list->dir_list_obj,
|
||||
__ASSERT(err == 0 && obj == dir_list->dir_list_obj,
|
||||
"Expecting first object to be the Directory Listing Object");
|
||||
|
||||
/* Init with len = 0 to reset data */
|
||||
|
|
@ -210,7 +210,7 @@ void bt_ots_dir_list_init(struct bt_ots_dir_list **dir_list, void *obj_manager)
|
|||
int err;
|
||||
static char *dir_list_obj_name = CONFIG_BT_OTS_DIR_LIST_OBJ_NAME;
|
||||
|
||||
__ASSERT(*dir_list, "Already initialized");
|
||||
__ASSERT(*dir_list == NULL, "Already initialized");
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(dir_lists); i++) {
|
||||
if (!dir_lists[i].dir_list_obj) {
|
||||
|
|
@ -226,7 +226,7 @@ void bt_ots_dir_list_init(struct bt_ots_dir_list **dir_list, void *obj_manager)
|
|||
|
||||
err = bt_gatt_ots_obj_manager_obj_add(obj_manager, &dir_list_obj);
|
||||
|
||||
__ASSERT(!err, "Could not add Directory Listing Object for object manager %p", obj_man);
|
||||
__ASSERT(!err, "Could not add Directory Listing Object for object manager %p", obj_manager);
|
||||
|
||||
memset(&dir_list_obj->metadata, 0, sizeof(dir_list_obj->metadata));
|
||||
dir_list_obj->metadata.name = dir_list_obj_name;
|
||||
|
|
|
|||
Loading…
Reference in a new issue