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/net/80211/net80211.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/net/80211') diff --git a/src/net/80211/net80211.c b/src/net/80211/net80211.c index ffa5c9110..d39958ba7 100644 --- a/src/net/80211/net80211.c +++ b/src/net/80211/net80211.c @@ -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; -- cgit v1.2.3-55-g7522