mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-20 03:44:55 +00:00
list: use list_count_nodes() to count list entries
Use the API function list_count_nodes() to count the number of list entries. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
e83ced1a24
commit
be222ac029
5 changed files with 8 additions and 22 deletions
|
@ -79,13 +79,7 @@ int scene_title_set(struct scene *scn, uint id)
|
||||||
|
|
||||||
int scene_obj_count(struct scene *scn)
|
int scene_obj_count(struct scene *scn)
|
||||||
{
|
{
|
||||||
struct scene_obj *obj;
|
return list_count_nodes(&scn->obj_head);
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
list_for_each_entry(obj, &scn->obj_head, sibling)
|
|
||||||
count++;
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *scene_obj_find(const struct scene *scn, uint id, enum scene_obj_t type)
|
void *scene_obj_find(const struct scene *scn, uint id, enum scene_obj_t type)
|
||||||
|
|
|
@ -581,13 +581,11 @@ static int count_fastmap_pebs(struct ubi_attach_info *ai)
|
||||||
struct ubi_ainf_peb *aeb;
|
struct ubi_ainf_peb *aeb;
|
||||||
struct ubi_ainf_volume *av;
|
struct ubi_ainf_volume *av;
|
||||||
struct rb_node *rb1, *rb2;
|
struct rb_node *rb1, *rb2;
|
||||||
int n = 0;
|
int n;
|
||||||
|
|
||||||
list_for_each_entry(aeb, &ai->erase, u.list)
|
n = list_count_nodes(&ai->erase);
|
||||||
n++;
|
|
||||||
|
|
||||||
list_for_each_entry(aeb, &ai->free, u.list)
|
n += list_count_nodes(&ai->free);
|
||||||
n++;
|
|
||||||
|
|
||||||
ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb)
|
ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb)
|
||||||
ubi_rb_for_each_entry(rb2, aeb, &av->root, u.rb)
|
ubi_rb_for_each_entry(rb2, aeb, &av->root, u.rb)
|
||||||
|
|
|
@ -4452,13 +4452,12 @@ loff_t yaffs_get_obj_length(struct yaffs_obj *obj)
|
||||||
int yaffs_get_obj_link_count(struct yaffs_obj *obj)
|
int yaffs_get_obj_link_count(struct yaffs_obj *obj)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
struct list_head *i;
|
|
||||||
|
|
||||||
if (!obj->unlinked)
|
if (!obj->unlinked)
|
||||||
count++; /* the object itself */
|
count++; /* the object itself */
|
||||||
|
|
||||||
list_for_each(i, &obj->hard_links)
|
/* add the hard links; */
|
||||||
count++; /* add the hard links; */
|
count += list_count_nodes(&obj->hard_links);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,10 +60,7 @@ int fwu_mtd_get_alt_num(efi_guid_t *image_id, u8 *alt_num,
|
||||||
if (ret)
|
if (ret)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
nalt = 0;
|
nalt = list_count_nodes(&dfu_list);
|
||||||
list_for_each_entry(dfu, &dfu_list, list)
|
|
||||||
nalt++;
|
|
||||||
|
|
||||||
if (!nalt) {
|
if (!nalt) {
|
||||||
log_warning("No entities in dfu_alt_info\n");
|
log_warning("No entities in dfu_alt_info\n");
|
||||||
dfu_free_entities();
|
dfu_free_entities();
|
||||||
|
|
|
@ -702,9 +702,7 @@ static int expo_test_build(struct unit_test_state *uts)
|
||||||
txt = scene_obj_find(scn, item->label_id, SCENEOBJT_NONE);
|
txt = scene_obj_find(scn, item->label_id, SCENEOBJT_NONE);
|
||||||
ut_asserteq_str("2 GHz", expo_get_str(exp, txt->str_id));
|
ut_asserteq_str("2 GHz", expo_get_str(exp, txt->str_id));
|
||||||
|
|
||||||
count = 0;
|
count = list_count_nodes(&menu->item_head);
|
||||||
list_for_each_entry(item, &menu->item_head, sibling)
|
|
||||||
count++;
|
|
||||||
ut_asserteq(3, count);
|
ut_asserteq(3, count);
|
||||||
|
|
||||||
expo_destroy(exp);
|
expo_destroy(exp);
|
||||||
|
|
Loading…
Add table
Reference in a new issue