/* An iterator function for menu items. callback will be called for each item in m, with m, a pointer to the item, and extra being passed to callback. If callback returns a value other than NULL, iteration stops and the value return by callback is returned from menu_items_iter. This allows it to be used for search type operations. It is also safe for callback to remove the item from the list of items.  */
static void* menu_items_iter(struct menu *m, void *(*callback)(struct menu *, struct menu_item *, void *), void *extra)
/* An iterator function for menu items. callback will be called for each item in m, with m, a pointer to the item, and extra being passed to callback. If callback returns a value other than NULL, iteration stops and the value return by callback is returned from menu_items_iter. This allows it to be used for search type operations. It is also safe for callback to remove the item from the list of items.  */
static void* menu_items_iter(struct menu *m, void *(*callback)(struct menu *, struct menu_item *, void *), void *extra)
{
	struct list_head *pos, *n;
	struct menu_item *item;
	void *ret;
	list_for_each_safe(pos, n, &m->items) {
		item = list_entry(pos, struct menu_item, list);
		ret = callback(m, item, extra);
		if (ret)
			return ret;
	}
	return NULL;
}