Skip to content

Commit 0e31692

Browse files
PavelVPVjukkar
authored andcommitted
[nrf fromtree] bluetooth: mesh: cfg_cli: Update logs when pulling out CDP0 and 1
This commits puts in order log messages when unpacking CDP0 and CDP1 so that it a bit more clear where the error happens. Signed-off-by: Pavel Vasilyev <[email protected]> (cherry picked from commit 1eeee01) Signed-off-by: Håvard Reierstad <[email protected]> (cherry picked from commit 7d31b72)
1 parent 7310fc7 commit 0e31692

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

subsys/bluetooth/mesh/cfg_cli.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2275,6 +2275,7 @@ struct bt_mesh_comp_p0_elem *bt_mesh_comp_p0_elem_pull(const struct bt_mesh_comp
22752275
size_t modlist_size;
22762276

22772277
if (page->_buf->len < 4) {
2278+
LOG_DBG("Buffer is too short");
22782279
return NULL;
22792280
}
22802281

@@ -2285,6 +2286,7 @@ struct bt_mesh_comp_p0_elem *bt_mesh_comp_p0_elem_pull(const struct bt_mesh_comp
22852286
modlist_size = elem->nsig * 2 + elem->nvnd * 4;
22862287

22872288
if (page->_buf->len < modlist_size) {
2289+
LOG_DBG("Buffer is shorter than number of claimed models");
22882290
return NULL;
22892291
}
22902292

@@ -2321,7 +2323,7 @@ struct bt_mesh_comp_p1_elem *bt_mesh_comp_p1_elem_pull(struct net_buf_simple *bu
23212323
struct bt_mesh_comp_p1_elem *elem)
23222324
{
23232325
if (buf->len < 4) {
2324-
LOG_DBG("No more elements to pull or missing data");
2326+
LOG_DBG("Buffer is too short");
23252327
return NULL;
23262328
}
23272329
size_t elem_size = 0;
@@ -2333,6 +2335,7 @@ struct bt_mesh_comp_p1_elem *bt_mesh_comp_p1_elem_pull(struct net_buf_simple *bu
23332335
elem->nvnd = net_buf_simple_pull_u8(buf);
23342336
for (i = 0; i < elem->nsig + elem->nvnd; i++) {
23352337
if (buf->len < elem_size + 1) {
2338+
LOG_DBG("Buffer is shorter than number of claimed models");
23362339
return NULL;
23372340
}
23382341

@@ -2351,6 +2354,7 @@ struct bt_mesh_comp_p1_elem *bt_mesh_comp_p1_elem_pull(struct net_buf_simple *bu
23512354
}
23522355

23532356
if (buf->len < elem_size) {
2357+
LOG_DBG("No more elements to pull or missing data");
23542358
return NULL;
23552359
}
23562360

@@ -2381,13 +2385,15 @@ struct bt_mesh_comp_p1_model_item *bt_mesh_comp_p1_item_pull(
23812385
item_size = item->ext_item_cnt * (item->format + 1);
23822386
if (item->cor_present) {
23832387
if (elem->_buf->len < 1) {
2388+
LOG_DBG("Coresponding_Present field is claimed but not present");
23842389
return NULL;
23852390
}
23862391

23872392
item->cor_id = net_buf_simple_pull_u8(elem->_buf);
23882393
}
23892394

23902395
if (elem->_buf->len < item_size) {
2396+
LOG_DBG("No more elements to pull or missing data");
23912397
return NULL;
23922398
}
23932399

0 commit comments

Comments
 (0)