[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/.

Holger Freyther holger at freyther.de
Thu Oct 8 09:05:21 UTC 2015


> On 07 Oct 2015, at 16:18, Neels Hofmeyr <nhofmeyr at sysmocom.de> wrote:
> 
> +/* TODO move this to osmocom/core/linuxlist.h ? */
> +#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?


> +int servers_read_cb(struct osmo_fd *servers_ofd, unsigned int what)
> +{
> +	unsigned int port_idx = servers_ofd->priv_nr;
> +	OSMO_ASSERT(port_idx < GTPH_PORT_N);
> +	LOG("reading from servers socket (%s)\n", gtphub_port_idx_names[port_idx]);
> +	if (!(what & BSC_FD_READ))
> +		return 0;
> +
> +	struct gtphub *hub = servers_ofd->data;
> +
> +	/* 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?





More information about the OpenBSC mailing list