From 5ad2f06333eacdff23d4b6d8edc6594da25bb651 Mon Sep 17 00:00:00 2001 From: Freddie Chopin Date: Thu, 5 Dec 2019 22:01:05 +0100 Subject: [PATCH] PPP, PPPoS: Use `const void*` instead of `u8_t*` in pppos_input() There is no good reason why this function should take a non-const pointer. While changing that also switch to a more generic `void*` instead of "byte". --- src/include/netif/ppp/pppos.h | 2 +- src/netif/ppp/pppos.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/include/netif/ppp/pppos.h b/src/include/netif/ppp/pppos.h index 0401d9ff..983da56c 100644 --- a/src/include/netif/ppp/pppos.h +++ b/src/include/netif/ppp/pppos.h @@ -106,7 +106,7 @@ err_t pppos_input_tcpip(ppp_pcb *ppp, const void *s, int l); #endif /* !NO_SYS && !PPP_INPROC_IRQ_SAFE */ /* PPP over Serial: this is the input function to be called for received data. */ -void pppos_input(ppp_pcb *ppp, u8_t* data, int len); +void pppos_input(ppp_pcb *ppp, const void* data, int len); /* diff --git a/src/netif/ppp/pppos.c b/src/netif/ppp/pppos.c index 1eb93430..37f8369f 100644 --- a/src/netif/ppp/pppos.c +++ b/src/netif/ppp/pppos.c @@ -477,10 +477,11 @@ PACK_STRUCT_END * @param l length of received data */ void -pppos_input(ppp_pcb *ppp, u8_t *s, int l) +pppos_input(ppp_pcb *ppp, const void *s, int l) { pppos_pcb *pppos = (pppos_pcb *)ppp->link_ctx_cb; struct pbuf *next_pbuf; + const u8_t *s_u8 = (const u8_t *)s; u8_t cur_char; u8_t escaped; PPPOS_DECL_PROTECT(lev); @@ -490,7 +491,7 @@ pppos_input(ppp_pcb *ppp, u8_t *s, int l) PPPDEBUG(LOG_DEBUG, ("pppos_input[%d]: got %d bytes\n", ppp->netif->num, l)); while (l-- > 0) { - cur_char = *s++; + cur_char = *s_u8++; PPPOS_PROTECT(lev); /* ppp_input can disconnect the interface, we need to abort to prevent a memory