On Thu, Oct 08, 2015 at 11:05:21AM +0200, Holger Freyther wrote: > > +#define __llist_first(head) (((head)->next == (head)) ? NULL : > > (head)->next) > > +#define llist_first(head, type, entry) llist_entry(__llist_first(head), > > type, entry) > > Why the null check? I mean > > struct *foo = llist_first(list); > if (!foo) > return > > vs. > > if (llist_empty(list)) > return; > struct *foo = llist_first(list); > > has no difference?
Almost. All it does is make sure I don't forget the emptiness check, really... a NULL dereference will more reliably result in a segfault than dereferencing a list item struct from an llist_head. But anyway: ... > > + /* TODO this will not be hardcoded. */ > > + struct gtphub_peer *client = > > llist_first(&hub->to_clients[port_idx].peers, > > + struct gtphub_peer, entry); > > interesting that you are the first to use the llist in this way. As you will > track > multiple peers the need for a llist_first will vanish? ... Indeed. ~Neels
signature.asc
Description: Digital signature
