From: Michael Brown Date: Tue, 3 May 2011 19:02:07 +0000 (+0100) Subject: [list] Add list_check_contains() X-Git-Tag: v1.20.1~2135 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df58a19015fe6ce8ec8b6624b618d3a2d563356c;p=thirdparty%2Fipxe.git [list] Add list_check_contains() Signed-off-by: Michael Brown --- diff --git a/src/include/ipxe/list.h b/src/include/ipxe/list.h index ab4c119dd..4905aaa3a 100644 --- a/src/include/ipxe/list.h +++ b/src/include/ipxe/list.h @@ -212,4 +212,23 @@ static inline int list_empty ( const struct list_head *list ) { pos = tmp, \ tmp = list_entry ( tmp->member.next, typeof ( *tmp ), member ) ) +/** + * Check list contains a specified entry + * + * @v entry Entry + * @v head List head + * @v member Name of list field within iterator's type + */ +#define list_check_contains( entry, head, member ) do { \ + if ( ASSERTING ) { \ + typeof ( entry ) tmp; \ + int found = 0; \ + list_for_each_entry ( tmp, head, member ) { \ + if ( tmp == entry ) \ + found = 1; \ + } \ + assert ( found ); \ + } \ + } while ( 0 ) + #endif /* _IPXE_LIST_H */