mirror of
https://github.com/ipxe/ipxe
synced 2025-12-19 02:50:25 +03:00
[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>
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user