mirror of https://github.com/ipxe/ipxe.git
[list] Tidy up naming convention for list_contains() and friends
Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/5/head
parent
12767d2202
commit
38b205d0a4
|
@ -170,6 +170,18 @@ static inline int list_empty ( const struct list_head *list ) {
|
||||||
( type * ) NULL : \
|
( type * ) NULL : \
|
||||||
list_entry ( (list)->next, type, member ) )
|
list_entry ( (list)->next, type, member ) )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterate over a list
|
||||||
|
*
|
||||||
|
* @v pos Iterator
|
||||||
|
* @v head List head
|
||||||
|
*/
|
||||||
|
#define list_for_each( pos, head ) \
|
||||||
|
for ( list_check ( (head) ), \
|
||||||
|
pos = (head)->next; \
|
||||||
|
pos != (head); \
|
||||||
|
pos = (pos)->next )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterate over entries in a list
|
* Iterate over entries in a list
|
||||||
*
|
*
|
||||||
|
@ -212,6 +224,38 @@ static inline int list_empty ( const struct list_head *list ) {
|
||||||
pos = tmp, \
|
pos = tmp, \
|
||||||
tmp = list_entry ( tmp->member.next, typeof ( *tmp ), member ) )
|
tmp = list_entry ( tmp->member.next, typeof ( *tmp ), member ) )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if list contains a specified entry
|
||||||
|
*
|
||||||
|
* @v entry Entry
|
||||||
|
* @v head List head
|
||||||
|
* @ret present List contains specified entry
|
||||||
|
*/
|
||||||
|
static inline int list_contains ( struct list_head *entry,
|
||||||
|
struct list_head *head ) {
|
||||||
|
struct list_head *tmp;
|
||||||
|
|
||||||
|
list_for_each ( tmp, head ) {
|
||||||
|
if ( tmp == entry )
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#define list_contains( entry, head ) ( { \
|
||||||
|
list_check ( (head) ); \
|
||||||
|
list_check ( (entry) ); \
|
||||||
|
list_contains ( (entry), (head) ); } )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if list contains a specified entry
|
||||||
|
*
|
||||||
|
* @v entry Entry
|
||||||
|
* @v head List head
|
||||||
|
* @ret present List contains specified entry
|
||||||
|
*/
|
||||||
|
#define list_contains_entry( entry, head, member ) \
|
||||||
|
list_contains ( &(entry)->member, (head) )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check list contains a specified entry
|
* Check list contains a specified entry
|
||||||
*
|
*
|
||||||
|
@ -219,16 +263,8 @@ static inline int list_empty ( const struct list_head *list ) {
|
||||||
* @v head List head
|
* @v head List head
|
||||||
* @v member Name of list field within iterator's type
|
* @v member Name of list field within iterator's type
|
||||||
*/
|
*/
|
||||||
#define list_check_contains( entry, head, member ) do { \
|
#define list_check_contains_entry( entry, head, member ) do { \
|
||||||
if ( ASSERTING ) { \
|
assert ( list_contains_entry ( (entry), (head), member ) ); \
|
||||||
typeof ( entry ) tmp; \
|
|
||||||
int found = 0; \
|
|
||||||
list_for_each_entry ( tmp, head, member ) { \
|
|
||||||
if ( tmp == entry ) \
|
|
||||||
found = 1; \
|
|
||||||
} \
|
|
||||||
assert ( found ); \
|
|
||||||
} \
|
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
|
|
||||||
#endif /* _IPXE_LIST_H */
|
#endif /* _IPXE_LIST_H */
|
||||||
|
|
|
@ -1625,7 +1625,7 @@ void fc_ulp_detach ( struct fc_ulp_user *user ) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
list_check_contains ( user, &ulp->users, list );
|
list_check_contains_entry ( user, &ulp->users, list );
|
||||||
|
|
||||||
/* Detach user and log out if no users remain */
|
/* Detach user and log out if no users remain */
|
||||||
list_del ( &user->list );
|
list_del ( &user->list );
|
||||||
|
|
|
@ -233,7 +233,7 @@ void netdev_tx_complete_err ( struct net_device *netdev,
|
||||||
struct io_buffer *iobuf, int rc ) {
|
struct io_buffer *iobuf, int rc ) {
|
||||||
|
|
||||||
/* Catch data corruption as early as possible */
|
/* Catch data corruption as early as possible */
|
||||||
list_check_contains ( iobuf, &netdev->tx_queue, list );
|
list_check_contains_entry ( iobuf, &netdev->tx_queue, list );
|
||||||
|
|
||||||
/* Dequeue and free I/O buffer */
|
/* Dequeue and free I/O buffer */
|
||||||
list_del ( &iobuf->list );
|
list_del ( &iobuf->list );
|
||||||
|
|
Loading…
Reference in New Issue