From ea631f6fb8dbffe3081ecf29eafa62ecd38ec64f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 8 Nov 2010 02:51:18 +0000 Subject: [list] Add list_first_entry() There are several points in the iPXE codebase where list_for_each_entry() is (ab)used to extract only the first entry from a list. Add a macro list_first_entry() to make this code easier to read. Signed-off-by: Michael Brown --- src/hci/commands/fcmgmt_cmd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/hci') diff --git a/src/hci/commands/fcmgmt_cmd.c b/src/hci/commands/fcmgmt_cmd.c index 3a4e28469..98647c134 100644 --- a/src/hci/commands/fcmgmt_cmd.c +++ b/src/hci/commands/fcmgmt_cmd.c @@ -144,12 +144,11 @@ static int fcels_exec ( int argc, char **argv ) { } } else { /* Use first port */ - if ( list_empty ( &fc_ports ) ) { + port = list_first_entry ( &fc_ports, struct fc_port, list ); + if ( ! port ) { printf ( "No ports\n" ); return 1; } - list_for_each_entry ( port, &fc_ports, list ) - break; } assert ( port != NULL ); -- cgit v1.2.3-55-g7522