From ef758082ed2fe543d6609ccb2b38383ced75f683 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Sun, 5 Feb 2017 12:35:42 +0100 Subject: [PATCH] Fix that slipif used netif->num to pass parameters to slipif_init. Use netif->state now, interpreted as u8_t port number (not a pointer any more!) --- UPGRADING | 4 ++++ src/netif/slipif.c | 17 ++++++----------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/UPGRADING b/UPGRADING index 3188efc6..8d7f67e8 100644 --- a/UPGRADING +++ b/UPGRADING @@ -9,6 +9,10 @@ with newer versions. * [Enter new changes just after this line - do not remove this line] ++ Application changes: + + * slipif: The way to pass serial port number has changed. netif->num is not + supported any more, netif->state is interpreted as an u8_t port number now + (it's not a POINTER to an u8_t any more!) * The IPv6 implementation now supports address scopes. All addresses that have a scope according to the default policy (link-local unicast addresses, interface-local and link-local multicast diff --git a/src/netif/slipif.c b/src/netif/slipif.c index 6eb83c35..e9c04b24 100644 --- a/src/netif/slipif.c +++ b/src/netif/slipif.c @@ -124,7 +124,7 @@ slipif_output(struct netif *netif, struct pbuf *p) LWIP_ASSERT("netif->state != NULL", (netif->state != NULL)); LWIP_ASSERT("p != NULL", (p != NULL)); - LWIP_DEBUGF(SLIP_DEBUG, ("slipif_output(%"U16_F"): sending %"U16_F" bytes\n", (u16_t)netif->num, p->tot_len)); + LWIP_DEBUGF(SLIP_DEBUG, ("slipif_output: sending %"U16_F" bytes\n", p->tot_len)); priv = (struct slipif_priv *)netif->state; /* Send pbuf out on the serial I/O device. */ @@ -352,9 +352,7 @@ slipif_loop_thread(void *nf) * ERR_MEM if no memory could be allocated, * ERR_IF is serial line couldn't be opened * - * @note netif->num must contain the number of the serial port to open - * (0 by default). If netif->state is != NULL, it is interpreted as an - * u8_t pointer pointing to the serial port number instead of netif->num. + * @note If netif->state is interpreted as an u8_t serial port number. * */ err_t @@ -363,7 +361,10 @@ slipif_init(struct netif *netif) struct slipif_priv *priv; u8_t sio_num; - LWIP_DEBUGF(SLIP_DEBUG, ("slipif_init: netif->num=%"U16_F"\n", (u16_t)netif->num)); + /* netif->state contains serial port number */ + sio_num = (u8_t)netif->state; + + LWIP_DEBUGF(SLIP_DEBUG, ("slipif_init: netif->num=%"U16_F"\n", (u16_t)sio_num)); /* Allocate private data */ priv = (struct slipif_priv *)mem_malloc(sizeof(struct slipif_priv)); @@ -381,12 +382,6 @@ slipif_init(struct netif *netif) #endif /* LWIP_IPV6 */ netif->mtu = SLIP_MAX_SIZE; - /* netif->state or netif->num contain the port number */ - if (netif->state != NULL) { - sio_num = *(u8_t*)netif->state; - } else { - sio_num = netif->num; - } /* Try to open the serial port. */ priv->sd = sio_open(sio_num); if (!priv->sd) {