[riot-notifications] [RIOT-OS/RIOT] gnrc/netif: add gnrc_netif_ipv6_wait_for_global_address() (#16824)

Martine Lenders notifications at github.com
Thu Sep 16 14:21:09 CEST 2021


@miri64 requested changes on this pull request.



> +static void _netif_bus_attach_and_subscribe(gnrc_netif_t *netif, msg_bus_entry_t *sub)
+{
+    msg_bus_t *bus = gnrc_netif_get_bus(netif, GNRC_NETIF_BUS_IPV6);
+    msg_bus_attach(bus, sub);
+    msg_bus_subscribe(sub, GNRC_IPV6_EVENT_ADDR_VALID);
+}

```suggestion
static void _netif_bus_attach_and_subscribe_addr_valid(gnrc_netif_t *netif, msg_bus_entry_t *sub)
{
    msg_bus_t *bus = gnrc_netif_get_bus(netif, GNRC_NETIF_BUS_IPV6);
    msg_bus_attach(bus, sub);
    msg_bus_subscribe(sub, GNRC_IPV6_EVENT_ADDR_VALID);
}
```

to reflect that you subscribe to the `GNRC_IPV6_EVENT_ADDR_VALID`? 

>          return has_global;
     }

```suggestion
    }
    else {
```

IMHO the less early returns, the better (and in case the optimizer gets confused it might also lead to smaller code size). Also I think that makes the code easier to understand: The if branch handles the "`netif` is set" case the else branch the "`netif` is unset".

> +static void _netif_bus_attach_and_subscribe(gnrc_netif_t *netif, msg_bus_entry_t *sub)
+{
+    msg_bus_t *bus = gnrc_netif_get_bus(netif, GNRC_NETIF_BUS_IPV6);
+    msg_bus_attach(bus, sub);
+    msg_bus_subscribe(sub, GNRC_IPV6_EVENT_ADDR_VALID);
+}

Alternatively, you could also provide the event-type as a parameter, to make this function more re-usable.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16824#pullrequestreview-756222440
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210916/3e24ca3c/attachment.htm>


More information about the notifications mailing list