int scene_obj_count(struct scene *scn)
{
- struct scene_obj *obj;
- int count = 0;
-
- list_for_each_entry(obj, &scn->obj_head, sibling)
- count++;
-
- return count;
+ return list_count_nodes(&scn->obj_head);
}
void *scene_obj_find(const struct scene *scn, uint id, enum scene_obj_t type)
struct ubi_ainf_peb *aeb;
struct ubi_ainf_volume *av;
struct rb_node *rb1, *rb2;
- int n = 0;
+ int n;
- list_for_each_entry(aeb, &ai->erase, u.list)
- n++;
+ n = list_count_nodes(&ai->erase);
- list_for_each_entry(aeb, &ai->free, u.list)
- n++;
+ n += list_count_nodes(&ai->free);
ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb)
ubi_rb_for_each_entry(rb2, aeb, &av->root, u.rb)
int yaffs_get_obj_link_count(struct yaffs_obj *obj)
{
int count = 0;
- struct list_head *i;
if (!obj->unlinked)
count++; /* the object itself */
- list_for_each(i, &obj->hard_links)
- count++; /* add the hard links; */
+ /* add the hard links; */
+ count += list_count_nodes(&obj->hard_links);
return count;
}
if (ret)
return -ENOENT;
- nalt = 0;
- list_for_each_entry(dfu, &dfu_list, list)
- nalt++;
-
+ nalt = list_count_nodes(&dfu_list);
if (!nalt) {
log_warning("No entities in dfu_alt_info\n");
dfu_free_entities();
txt = scene_obj_find(scn, item->label_id, SCENEOBJT_NONE);
ut_asserteq_str("2 GHz", expo_get_str(exp, txt->str_id));
- count = 0;
- list_for_each_entry(item, &menu->item_head, sibling)
- count++;
+ count = list_count_nodes(&menu->item_head);
ut_asserteq(3, count);
expo_destroy(exp);