From 759d11ce1a15cb2c2e5b55d1bb92c3b37919c5b4 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Fri, 20 Feb 2015 00:03:47 +0100 Subject: [PATCH] PPP, CORE, beautified ppp_ioctl() --- src/netif/ppp/ppp.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 65ed2610..eb901d91 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -345,28 +345,25 @@ ppp_ioctl(ppp_pcb *pcb, int cmd, void *arg) switch(cmd) { case PPPCTLG_UPSTATUS: /* Get the PPP up status. */ - if (arg) { - *(int *)arg = (int)(pcb->if_up); - return PPPERR_NONE; + if (!arg) { + goto fail; } - return PPPERR_PARAM; - break; + *(int *)arg = (int)(pcb->if_up); + return PPPERR_NONE; case PPPCTLS_ERRCODE: /* Set the PPP error code. */ - if (arg) { - pcb->err_code = (u8_t)(*(int *)arg); - return PPPERR_NONE; + if (!arg) { + goto fail; } - return PPPERR_PARAM; - break; + pcb->err_code = (u8_t)(*(int *)arg); + return PPPERR_NONE; case PPPCTLG_ERRCODE: /* Get the PPP error code. */ - if (arg) { - *(int *)arg = (int)(pcb->err_code); - return PPPERR_NONE; + if (!arg) { + goto fail; } - return PPPERR_PARAM; - break; + *(int *)arg = (int)(pcb->err_code); + return PPPERR_NONE; default: if (pcb->link_cb->ioctl) { @@ -374,6 +371,7 @@ ppp_ioctl(ppp_pcb *pcb, int cmd, void *arg) } } +fail: return PPPERR_PARAM; }