[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:
Michael Brown
2010-11-08 02:51:18 +00:00
parent 295ba15bd6
commit ea631f6fb8
7 changed files with 41 additions and 28 deletions

View File

@@ -1014,9 +1014,8 @@ static void tcp_process_rx_queue ( struct tcp_connection *tcp ) {
* queue, since tcp_discard() may remove packets from the RX
* queue while we are processing.
*/
while ( ! list_empty ( &tcp->rx_queue ) ) {
list_for_each_entry ( iobuf, &tcp->rx_queue, list )
break;
while ( ( iobuf = list_first_entry ( &tcp->rx_queue, struct io_buffer,
list ) ) ) {
/* Stop processing when we hit the first gap */
tcpqhdr = iobuf->data;