From 7c368b7f369fb410d4a5a45c82b24c460f3d214c Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sat, 2 Jul 2016 15:11:02 +0200 Subject: [PATCH] PPP, PPPoS: use offsetof in place of the traditional NULL hack There is absolutely no reason I did it this way in the first place, maybe I feared that not all compilers have a proper implementation of offsetof() ? It sounds stupid. --- src/netif/ppp/pppos.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/netif/ppp/pppos.c b/src/netif/ppp/pppos.c index d2aa97d4..006971d9 100644 --- a/src/netif/ppp/pppos.c +++ b/src/netif/ppp/pppos.c @@ -35,6 +35,7 @@ #if PPP_SUPPORT && PPPOS_SUPPORT /* don't build if not configured for use in lwipopts.h */ #include +#include #include "lwip/err.h" #include "lwip/pbuf.h" @@ -310,7 +311,7 @@ pppos_connect(ppp_pcb *ppp, void *ctx) ppp_link_start(ppp); /* reset PPPoS control block to its initial state */ - memset(&pppos->last_xmit, 0, sizeof(pppos_pcb) - ( (char*)&((pppos_pcb*)0)->last_xmit - (char*)0 ) ); + memset(&pppos->last_xmit, 0, sizeof(pppos_pcb) - offsetof(pppos_pcb, last_xmit)); /* * Default the in and out accm so that escape and flag characters @@ -344,7 +345,7 @@ pppos_listen(ppp_pcb *ppp, void *ctx) ppp_link_start(ppp); /* reset PPPoS control block to its initial state */ - memset(&pppos->last_xmit, 0, sizeof(pppos_pcb) - ( (char*)&((pppos_pcb*)0)->last_xmit - (char*)0 ) ); + memset(&pppos->last_xmit, 0, sizeof(pppos_pcb) - offsetof(pppos_pcb, last_xmit)); /* * Default the in and out accm so that escape and flag characters