From 9de1c71ff75059959a24ece32f0b4a552dd10892 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Mon, 2 Mar 2015 00:05:55 +0100 Subject: [PATCH] PPP, PPPoE, removed global static buffer only used for debug pppoe_error_tmp[] was only used in one function and only for debug purposes, moved to stack. --- src/netif/ppp/pppoe.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/netif/ppp/pppoe.c b/src/netif/ppp/pppoe.c index 1eeddcfc..e3a6e442 100644 --- a/src/netif/ppp/pppoe.c +++ b/src/netif/ppp/pppoe.c @@ -109,11 +109,7 @@ #define IFF_PASSIVE IFF_LINK0 /* wait passively for connection */ #endif -/* FIXME: we should probably remove that, this is only used for debug purposes */ -#ifndef PPPOE_ERRORSTRING_LEN #define PPPOE_ERRORSTRING_LEN 64 -#endif -static char pppoe_error_tmp[PPPOE_ERRORSTRING_LEN]; /* callbacks called from PPP core */ @@ -503,16 +499,19 @@ pppoe_disc_input(struct netif *netif, struct pbuf *pb) default: break; } +#if PPP_DEBUG if (NULL != err_msg) { if (len) { - u16_t error_len = LWIP_MIN(len, sizeof(pppoe_error_tmp)-1); - strncpy(pppoe_error_tmp, (char*)pb->payload + off + sizeof(pt), error_len); - pppoe_error_tmp[error_len] = '\0'; - PPPDEBUG(LOG_DEBUG, ("%s: %s: %s\n", devname, err_msg, pppoe_error_tmp)); + char error_tmp[PPPOE_ERRORSTRING_LEN]; + u16_t error_len = LWIP_MIN(len, sizeof(error_tmp)-1); + strncpy(error_tmp, (char*)pb->payload + off + sizeof(pt), error_len); + error_tmp[error_len] = '\0'; + PPPDEBUG(LOG_DEBUG, ("%s: %s: %s\n", devname, err_msg, error_tmp)); } else { PPPDEBUG(LOG_DEBUG, ("%s: %s\n", devname, err_msg)); } } +#endif /* PPP_DEBUG */ off += sizeof(pt) + len; }