summaryrefslogtreecommitdiffstats
path: root/common/menu.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2010-08-21 18:27:31 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2010-08-30 20:57:20 +0200
commit417e2d45fed238ed3f71e6c771bb84dbfc02c790 (patch)
tree56897fae86fbd2c883316be1546efaca53d42836 /common/menu.c
parentb11b88de64366210e6bb7a5e669bd6f4e770ccd7 (diff)
downloadbarebox-417e2d45fed238ed3f71e6c771bb84dbfc02c790.tar.gz
barebox-417e2d45fed238ed3f71e6c771bb84dbfc02c790.tar.xz
menu: use list_for_each_entry where appropriate
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/menu.c')
-rw-r--r--common/menu.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/common/menu.c b/common/menu.c
index 27c591a317..3596e215fd 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -93,7 +93,6 @@ int menu_add_entry(struct menu *m, struct menu_entry *me)
void menu_remove_entry(struct menu *m, struct menu_entry *me)
{
- struct list_head *pos;
int i = 1;
if (!m || !me)
@@ -102,22 +101,18 @@ void menu_remove_entry(struct menu *m, struct menu_entry *me)
m->nb_entries--;
list_del(&me->list);
- list_for_each(pos, &m->entries) {
- me = list_entry(pos, struct menu_entry, list);
+ list_for_each_entry(me, &m->entries, list)
me->num = i++;
- }
}
struct menu* menu_get_by_name(char *name)
{
- struct list_head *pos;
struct menu* m;
if (!name)
return NULL;
- list_for_each(pos, &menus.list) {
- m = list_entry(pos, struct menu, list);
+ list_for_each_entry(m, &menus.list, list) {
if(strcmp(m->name, name) == 0)
return m;
}
@@ -127,14 +122,12 @@ struct menu* menu_get_by_name(char *name)
struct menu_entry* menu_entry_get_by_num(struct menu* m, int num)
{
- struct list_head *pos;
struct menu_entry* me;
if (!m || num < 1 || num > m->nb_entries)
return NULL;
- list_for_each(pos, &m->entries) {
- me = list_entry(pos, struct menu_entry, list);
+ list_for_each_entry(me, &m->entries, list) {
if(me->num == num)
return me;
}
@@ -162,14 +155,12 @@ static void print_menu_entry(struct menu *m, struct menu_entry *me, int reverse)
int menu_set_selected_entry(struct menu *m, struct menu_entry* me)
{
- struct list_head *pos;
struct menu_entry* tmp;
if (!m || !me)
return -EINVAL;
- list_for_each(pos, &m->entries) {
- tmp = list_entry(pos, struct menu_entry, list);
+ list_for_each_entry(tmp, &m->entries, list) {
if(me == tmp) {
m->selected = me;
return 0;
@@ -195,7 +186,6 @@ int menu_set_selected(struct menu *m, int num)
static void print_menu(struct menu *m)
{
- struct list_head *pos;
struct menu_entry *me;
clear();
@@ -207,8 +197,7 @@ static void print_menu(struct menu *m)
puts(m->name);
}
- list_for_each(pos, &m->entries) {
- me = list_entry(pos, struct menu_entry, list);
+ list_for_each_entry(me, &m->entries, list) {
if(m->selected != me)
print_menu_entry(m, me, 0);
}