diff options
author | Michael Brown | 2010-11-08 03:51:18 +0100 |
---|---|---|
committer | Michael Brown | 2010-11-08 04:15:28 +0100 |
commit | ea631f6fb8dbffe3081ecf29eafa62ecd38ec64f (patch) | |
tree | f27d347fc48c524e172a4bdeea80976a26b9904a /src/net/infiniband.c | |
parent | [list] Extend list-manipulation assertions to all list-handling functions (diff) | |
download | ipxe-ea631f6fb8dbffe3081ecf29eafa62ecd38ec64f.tar.gz ipxe-ea631f6fb8dbffe3081ecf29eafa62ecd38ec64f.tar.xz ipxe-ea631f6fb8dbffe3081ecf29eafa62ecd38ec64f.zip |
[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 <mcb30@ipxe.org>
Diffstat (limited to 'src/net/infiniband.c')
-rw-r--r-- | src/net/infiniband.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/net/infiniband.c b/src/net/infiniband.c index bdfc45d6..a6e4233a 100644 --- a/src/net/infiniband.c +++ b/src/net/infiniband.c @@ -982,12 +982,12 @@ struct ib_device * find_ibdev ( union ib_gid *gid ) { struct ib_device * last_opened_ibdev ( void ) { struct ib_device *ibdev; - list_for_each_entry ( ibdev, &open_ib_devices, open_list ) { - assert ( ibdev->open_count != 0 ); - return ibdev; - } + ibdev = list_first_entry ( &open_ib_devices, struct ib_device, list ); + if ( ! ibdev ) + return NULL; - return NULL; + assert ( ibdev->open_count != 0 ); + return ibdev; } /* Drag in IPoIB */ |