From e158f87286512f5a6bba3c52bad06953e8eae6cd Mon Sep 17 00:00:00 2001 From: Joel Cunningham Date: Fri, 20 Jan 2017 14:49:11 -0600 Subject: [PATCH] Netif: add allowance for init to override netif->num Adjusts assert logic from 9c80a6625344768572777accbe77ac968c10250f to allow for a netif driver's init callback to manually override the number. When the init function is taking care of the unique assignment, the assert simply checks that a valid number was provided --- src/core/netif.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/netif.c b/src/core/netif.c index b2fb80c5..d998288f 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -300,7 +300,6 @@ netif_add(struct netif *netif, /* remember netif specific state information data */ netif->state = state; netif->num = netif_num++; - LWIP_ASSERT("Netif num overflow, too many netifs or adds/removes", netif->num < 255); netif->input = input; NETIF_SET_HWADDRHINT(netif, NULL); @@ -317,6 +316,11 @@ netif_add(struct netif *netif, return NULL; } + /* check that netif_num has not overflowed or that init callback + provided a valid number (we don't support 255 since that can't be + converted to an index) */ + LWIP_ASSERT("Netif num overflow/invalid num", netif->num < 255); + /* add this netif to the list */ netif->next = netif_list; netif_list = netif;