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.
This commit is contained in:
Sylvain Rochet 2015-03-02 00:05:55 +01:00
parent 3ce6dd166c
commit 9de1c71ff7

View File

@ -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;
}