[PATCH 05/10] gtphub: populate API impl from test prog

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Neels Hofmeyr nhofmeyr at sysmocom.de
Thu Oct 8 11:58:53 UTC 2015


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.osmocom.org/pipermail/openbsc/attachments/20151008/f9929ff4/attachment.bin>


More information about the OpenBSC mailing list