mirror of
https://github.com/ipxe/ipxe
synced 2025-12-27 01:52:39 +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:
@@ -668,11 +668,11 @@ struct io_buffer * net80211_mgmt_dequeue ( struct net80211_device *dev,
|
||||
*signal = rxi->signal;
|
||||
free ( rxi );
|
||||
|
||||
list_for_each_entry ( iobuf, &dev->mgmt_queue, list ) {
|
||||
list_del ( &iobuf->list );
|
||||
return iobuf;
|
||||
}
|
||||
assert ( 0 );
|
||||
assert ( ! list_empty ( &dev->mgmt_queue ) );
|
||||
iobuf = list_first_entry ( &dev->mgmt_queue, struct io_buffer,
|
||||
list );
|
||||
list_del ( &iobuf->list );
|
||||
return iobuf;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user