From 61e5301d49ed1f5ca7dd0c14b08f200408bb4eb2 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Sun, 24 Jan 2010 13:19:34 +0000 Subject: [PATCH] bug #26523: Compiler Warnings --- src/include/netif/ppp_oe.h | 63 +++++++++++++++++++------------------- src/netif/ppp/auth.c | 4 +-- src/netif/ppp/auth.h | 2 +- src/netif/ppp/chap.c | 11 ++++--- src/netif/ppp/chap.h | 6 ++-- src/netif/ppp/ipcp.c | 2 +- src/netif/ppp/lcp.c | 7 +++-- src/netif/ppp/pap.c | 6 ++-- src/netif/ppp/ppp.c | 19 ++++++------ src/netif/ppp/ppp.h | 6 ++-- src/netif/ppp/ppp_oe.c | 25 +++++++++------ src/netif/ppp/vj.c | 26 ++++++++-------- 12 files changed, 94 insertions(+), 83 deletions(-) diff --git a/src/include/netif/ppp_oe.h b/src/include/netif/ppp_oe.h index 3aa55aec..930ee2b2 100644 --- a/src/include/netif/ppp_oe.h +++ b/src/include/netif/ppp_oe.h @@ -79,10 +79,10 @@ #endif PACK_STRUCT_BEGIN struct pppoehdr { - PACK_STRUCT_FIELD(u8_t vertype); - PACK_STRUCT_FIELD(u8_t code); - PACK_STRUCT_FIELD(u16_t session); - PACK_STRUCT_FIELD(u16_t plen); + PACK_STRUCT_FIELD(u8_t vertype); + PACK_STRUCT_FIELD(u8_t code); + PACK_STRUCT_FIELD(u16_t session); + PACK_STRUCT_FIELD(u16_t plen); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES @@ -94,8 +94,8 @@ PACK_STRUCT_END #endif PACK_STRUCT_BEGIN struct pppoetag { - PACK_STRUCT_FIELD(u16_t tag); - PACK_STRUCT_FIELD(u16_t len); + PACK_STRUCT_FIELD(u16_t tag); + PACK_STRUCT_FIELD(u16_t len); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES @@ -103,40 +103,40 @@ PACK_STRUCT_END #endif -#define PPPOE_STATE_INITIAL 0 -#define PPPOE_STATE_PADI_SENT 1 -#define PPPOE_STATE_PADR_SENT 2 -#define PPPOE_STATE_SESSION 3 -#define PPPOE_STATE_CLOSING 4 +#define PPPOE_STATE_INITIAL 0 +#define PPPOE_STATE_PADI_SENT 1 +#define PPPOE_STATE_PADR_SENT 2 +#define PPPOE_STATE_SESSION 3 +#define PPPOE_STATE_CLOSING 4 /* passive */ -#define PPPOE_STATE_PADO_SENT 1 +#define PPPOE_STATE_PADO_SENT 1 -#define PPPOE_HEADERLEN sizeof(struct pppoehdr) -#define PPPOE_VERTYPE 0x11 /* VER=1, TYPE = 1 */ +#define PPPOE_HEADERLEN sizeof(struct pppoehdr) +#define PPPOE_VERTYPE 0x11 /* VER=1, TYPE = 1 */ -#define PPPOE_TAG_EOL 0x0000 /* end of list */ -#define PPPOE_TAG_SNAME 0x0101 /* service name */ -#define PPPOE_TAG_ACNAME 0x0102 /* access concentrator name */ -#define PPPOE_TAG_HUNIQUE 0x0103 /* host unique */ -#define PPPOE_TAG_ACCOOKIE 0x0104 /* AC cookie */ -#define PPPOE_TAG_VENDOR 0x0105 /* vendor specific */ -#define PPPOE_TAG_RELAYSID 0x0110 /* relay session id */ -#define PPPOE_TAG_SNAME_ERR 0x0201 /* service name error */ -#define PPPOE_TAG_ACSYS_ERR 0x0202 /* AC system error */ -#define PPPOE_TAG_GENERIC_ERR 0x0203 /* gerneric error */ +#define PPPOE_TAG_EOL 0x0000 /* end of list */ +#define PPPOE_TAG_SNAME 0x0101 /* service name */ +#define PPPOE_TAG_ACNAME 0x0102 /* access concentrator name */ +#define PPPOE_TAG_HUNIQUE 0x0103 /* host unique */ +#define PPPOE_TAG_ACCOOKIE 0x0104 /* AC cookie */ +#define PPPOE_TAG_VENDOR 0x0105 /* vendor specific */ +#define PPPOE_TAG_RELAYSID 0x0110 /* relay session id */ +#define PPPOE_TAG_SNAME_ERR 0x0201 /* service name error */ +#define PPPOE_TAG_ACSYS_ERR 0x0202 /* AC system error */ +#define PPPOE_TAG_GENERIC_ERR 0x0203 /* gerneric error */ -#define PPPOE_CODE_PADI 0x09 /* Active Discovery Initiation */ -#define PPPOE_CODE_PADO 0x07 /* Active Discovery Offer */ -#define PPPOE_CODE_PADR 0x19 /* Active Discovery Request */ -#define PPPOE_CODE_PADS 0x65 /* Active Discovery Session confirmation */ -#define PPPOE_CODE_PADT 0xA7 /* Active Discovery Terminate */ +#define PPPOE_CODE_PADI 0x09 /* Active Discovery Initiation */ +#define PPPOE_CODE_PADO 0x07 /* Active Discovery Offer */ +#define PPPOE_CODE_PADR 0x19 /* Active Discovery Request */ +#define PPPOE_CODE_PADS 0x65 /* Active Discovery Session confirmation */ +#define PPPOE_CODE_PADT 0xA7 /* Active Discovery Terminate */ #ifndef ETHERMTU #define ETHERMTU 1500 #endif /* two byte PPP protocol discriminator, then IP data */ -#define PPPOE_MAXMTU (ETHERMTU-PPPOE_HEADERLEN-2) +#define PPPOE_MAXMTU (ETHERMTU-PPPOE_HEADERLEN-2) struct pppoe_softc; @@ -154,7 +154,8 @@ void pppoe_data_input(struct netif *netif, struct pbuf *p); err_t pppoe_xmit(struct pppoe_softc *sc, struct pbuf *pb); -extern int pppoe_hdrlen; +/** used in ppp.c */ +#define PPPOE_HDRLEN (sizeof(struct eth_hdr) + PPPOE_HEADERLEN) #endif /* PPPOE_SUPPORT */ diff --git a/src/netif/ppp/auth.c b/src/netif/ppp/auth.c index 9974a114..c86c982e 100644 --- a/src/netif/ppp/auth.c +++ b/src/netif/ppp/auth.c @@ -862,7 +862,7 @@ auth_reset(int unit) * UPAP_AUTHACK: Authentication succeeded. * In either case, msg points to an appropriate message. */ -int +u_char check_passwd( int unit, char *auser, int userlen, char *apasswd, int passwdlen, char **msg, int *msglen) { #if 1 /* XXX Assume all entries OK. */ @@ -875,7 +875,7 @@ check_passwd( int unit, char *auser, int userlen, char *apasswd, int passwdlen, *msg = (char *) 0; return UPAP_AUTHACK; /* XXX Assume all entries OK. */ #else - int ret = 0; + u_char ret = 0; struct wordlist *addrs = NULL; char passwd[256], user[256]; char secret[MAXWORDLEN]; diff --git a/src/netif/ppp/auth.h b/src/netif/ppp/auth.h index 86ff0494..a8069ec4 100644 --- a/src/netif/ppp/auth.h +++ b/src/netif/ppp/auth.h @@ -97,7 +97,7 @@ void auth_check_options (void); void auth_reset (int); /* Check peer-supplied username/password */ -int check_passwd (int, char *, int, char *, int, char **, int *); +u_char check_passwd (int, char *, int, char *, int, char **, int *); /* get "secret" for chap */ int get_secret (int, char *, char *, char *, int *, int); diff --git a/src/netif/ppp/chap.c b/src/netif/ppp/chap.c index 8161e58e..016b61f9 100644 --- a/src/netif/ppp/chap.c +++ b/src/netif/ppp/chap.c @@ -141,7 +141,7 @@ chap_state chap[NUM_PPP]; /* CHAP state; one for each unit */ static void ChapChallengeTimeout (void *); static void ChapResponseTimeout (void *); -static void ChapReceiveChallenge (chap_state *, u_char *, int, int); +static void ChapReceiveChallenge (chap_state *, u_char *, u_char, int); static void ChapRechallenge (void *); static void ChapReceiveResponse (chap_state *, u_char *, int, int); static void ChapReceiveSuccess(chap_state *cstate, u_char *inp, u_char id, int len); @@ -174,7 +174,7 @@ ChapInit(int unit) * */ void -ChapAuthWithPeer(int unit, char *our_name, int digest) +ChapAuthWithPeer(int unit, char *our_name, u_char digest) { chap_state *cstate = &chap[unit]; @@ -201,7 +201,7 @@ ChapAuthWithPeer(int unit, char *our_name, int digest) * ChapAuthPeer - Authenticate our peer (start server). */ void -ChapAuthPeer(int unit, char *our_name, int digest) +ChapAuthPeer(int unit, char *our_name, u_char digest) { chap_state *cstate = &chap[unit]; @@ -420,7 +420,7 @@ ChapInput(int unit, u_char *inpacket, int packet_len) * ChapReceiveChallenge - Receive Challenge and send Response. */ static void -ChapReceiveChallenge(chap_state *cstate, u_char *inp, int id, int len) +ChapReceiveChallenge(chap_state *cstate, u_char *inp, u_char id, int len) { int rchallenge_len; u_char *rchallenge; @@ -791,7 +791,8 @@ ChapGenChallenge(chap_state *cstate) ((((magic() >> 16) * (MAX_CHALLENGE_LENGTH - MIN_CHALLENGE_LENGTH)) >> 16) + MIN_CHALLENGE_LENGTH); - cstate->chal_len = chal_len; + LWIP_ASSERT("chal_len <= 0xff", chal_len <= 0xffff); + cstate->chal_len = (u_char)chal_len; cstate->chal_id = ++cstate->id; cstate->chal_transmits = 0; diff --git a/src/netif/ppp/chap.h b/src/netif/ppp/chap.h index 00300df1..fedcab8d 100644 --- a/src/netif/ppp/chap.h +++ b/src/netif/ppp/chap.h @@ -62,7 +62,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: chap.h,v 1.5 2009/12/31 17:08:08 goldsimon Exp $ + * $Id: chap.h,v 1.6 2010/01/24 13:19:34 goldsimon Exp $ */ #ifndef CHAP_H @@ -142,8 +142,8 @@ typedef struct chap_state { extern chap_state chap[]; -void ChapAuthWithPeer (int, char *, int); -void ChapAuthPeer (int, char *, int); +void ChapAuthWithPeer (int, char *, u_char); +void ChapAuthPeer (int, char *, u_char); extern struct protent chap_protent; diff --git a/src/netif/ppp/ipcp.c b/src/netif/ppp/ipcp.c index e530d067..cf25f476 100644 --- a/src/netif/ppp/ipcp.c +++ b/src/netif/ppp/ipcp.c @@ -907,7 +907,7 @@ ipcp_reqci(fsm *f, u_char *inp/* Requested CIs */,int *len/* Length of requested p[1] > l) { /* CI length too big? */ IPCPDEBUG((LOG_INFO, "ipcp_reqci: bad CI length!\n")); orc = CONFREJ; /* Reject bad CI */ - cilen = l; /* Reject till end of packet */ + cilen = (u_short)l;/* Reject till end of packet */ l = 0; /* Don't loop again */ goto endswitch; } diff --git a/src/netif/ppp/lcp.c b/src/netif/ppp/lcp.c index 3a8da24e..db49e0c1 100644 --- a/src/netif/ppp/lcp.c +++ b/src/netif/ppp/lcp.c @@ -1230,7 +1230,8 @@ lcp_reqci(fsm *f, lcp_options *ho = &lcp_hisoptions[f->unit]; lcp_options *ao = &lcp_allowoptions[f->unit]; u_char *cip, *next; /* Pointer to current and next CIs */ - int cilen, citype, cichar; /* Parsed len, type, char value */ + int cilen, citype; /* Parsed len, type */ + u_char cichar; /* Parsed char value */ u_short cishort; /* Parsed short value */ u32_t cilong; /* Parse long value */ int rc = CONFACK; /* Final packet return code */ @@ -1416,7 +1417,7 @@ lcp_reqci(fsm *f, && cichar != CHAP_MICROSOFT #endif ) { - LCPDEBUG((LOG_WARNING, "lcp_reqci: Nak AUTHTYPE CHAP digest=%d\n", cichar)); + LCPDEBUG((LOG_WARNING, "lcp_reqci: Nak AUTHTYPE CHAP digest=%d\n", (int)cichar)); orc = CONFNAK; PUTCHAR(CI_AUTHTYPE, nakp); PUTCHAR(CILEN_CHAP, nakp); @@ -1425,7 +1426,7 @@ lcp_reqci(fsm *f, break; } #if TRACELCP > 0 - snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CHAP %X,%d", cishort, cichar); + snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CHAP %X,%d", cishort, (int)cichar); traceNdx = strlen(traceBuf); #endif ho->chap_mdtype = cichar; /* save md type */ diff --git a/src/netif/ppp/pap.c b/src/netif/ppp/pap.c index 0b88d6b5..bf9b3a5d 100644 --- a/src/netif/ppp/pap.c +++ b/src/netif/ppp/pap.c @@ -122,7 +122,7 @@ upap_state upap[NUM_PPP]; /* UPAP state; one for each unit */ static void upap_timeout (void *); static void upap_reqtimeout(void *); -static void upap_rauthreq (upap_state *, u_char *, int, int); +static void upap_rauthreq (upap_state *, u_char *, u_char, int); static void upap_rauthack (upap_state *, u_char *, int, int); static void upap_rauthnak (upap_state *, u_char *, int, int); static void upap_sauthreq (upap_state *); @@ -385,11 +385,11 @@ upap_input(int unit, u_char *inpacket, int l) * upap_rauth - Receive Authenticate. */ static void -upap_rauthreq(upap_state *u, u_char *inp, int id, int len) +upap_rauthreq(upap_state *u, u_char *inp, u_char id, int len) { u_char ruserlen, rpasswdlen; char *ruser, *rpasswd; - int retcode; + u_char retcode; char *msg; int msglen; diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 3f9f7fd9..cec00164 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -200,7 +200,7 @@ typedef struct PPPControl_s { #if PPPOS_SUPPORT sio_fd_t fd; /* File device ID of port. */ #endif /* PPPOS_SUPPORT */ - int mtu; /* Peer's mru */ + u16_t mtu; /* Peer's mru */ int pcomp; /* Does peer accept protocol compression? */ int accomp; /* Does peer accept addr/ctl compression? */ u_long lastXMit; /* Time of last transmission. */ @@ -764,14 +764,14 @@ pppifOutputOverEthernet(int pd, struct pbuf *p) u_short protocol = PPP_IP; int i=0; - pb = pbuf_alloc(PBUF_LINK, pppoe_hdrlen + sizeof(protocol), PBUF_RAM); + pb = pbuf_alloc(PBUF_LINK, PPPOE_HDRLEN + sizeof(protocol), PBUF_RAM); if(!pb) { LINK_STATS_INC(link.memerr); LINK_STATS_INC(link.proterr); return ERR_MEM; } - pbuf_header(pb, -pppoe_hdrlen); + pbuf_header(pb, -(s16_t)PPPOE_HDRLEN); pc->lastXMit = sys_jiffies(); @@ -991,11 +991,11 @@ pppIOCtl(int pd, int cmd, void *arg) /* * Return the Maximum Transmission Unit for the given PPP connection. */ -u_int +u_short pppMTU(int pd) { PPPControl *pc = &pppControl[pd]; - u_int st; + u_short st; /* Validate parameters. */ if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { @@ -1018,14 +1018,15 @@ pppWriteOverEthernet(int pd, const u_char *s, int n) s += 2; n -= 2; - pb = pbuf_alloc(PBUF_LINK, pppoe_hdrlen + n, PBUF_RAM); + LWIP_ASSERT("PPPOE_HDRLEN + n <= 0xffff", PPPOE_HDRLEN + n <= 0xffff); + pb = pbuf_alloc(PBUF_LINK, (u16_t)(PPPOE_HDRLEN + n), PBUF_RAM); if(!pb) { LINK_STATS_INC(link.memerr); LINK_STATS_INC(link.proterr); return PPPERR_ALLOC; } - pbuf_header(pb, -pppoe_hdrlen); + pbuf_header(pb, -(s16_t)PPPOE_HDRLEN); pc->lastXMit = sys_jiffies(); @@ -1123,7 +1124,7 @@ pppWrite(int pd, const u_char *s, int n) * the ppp interface. */ void -ppp_send_config( int unit, int mtu, u32_t asyncmap, int pcomp, int accomp) +ppp_send_config( int unit, u16_t mtu, u32_t asyncmap, int pcomp, int accomp) { PPPControl *pc = &pppControl[unit]; int i; @@ -1271,7 +1272,7 @@ GetMask(u32_t addr) * sifvjcomp - config tcp header compression */ int -sifvjcomp(int pd, int vjcomp, int cidcomp, int maxcid) +sifvjcomp(int pd, int vjcomp, u8_t cidcomp, u8_t maxcid) { #if PPPOS_SUPPORT && VJ_SUPPORT PPPControl *pc = &pppControl[pd]; diff --git a/src/netif/ppp/ppp.h b/src/netif/ppp/ppp.h index a8c81135..58d8643a 100644 --- a/src/netif/ppp/ppp.h +++ b/src/netif/ppp/ppp.h @@ -424,7 +424,7 @@ int pppIOCtl(int pd, int cmd, void *arg); /* * Return the Maximum Transmission Unit for the given PPP connection. */ -u_int pppMTU(int pd); +u_short pppMTU(int pd); /* * Write n characters to a ppp link. @@ -443,7 +443,7 @@ void pppLinkDown(int pd); void pppos_input(int pd, u_char* data, int len); /* Configure i/f transmit parameters */ -void ppp_send_config (int, int, u32_t, int, int); +void ppp_send_config (int, u16_t, u32_t, int, int); /* Set extended transmit ACCM */ void ppp_set_xaccm (int, ext_accm *); /* Configure i/f receive parameters */ @@ -452,7 +452,7 @@ void ppp_recv_config (int, int, u32_t, int, int); int get_idle_time (int, struct ppp_idle *); /* Configure VJ TCP header compression */ -int sifvjcomp (int, int, int, int); +int sifvjcomp (int, int, u8_t, u8_t); /* Configure i/f down (for IP) */ int sifup (int); /* Set mode for handling packets for proto */ diff --git a/src/netif/ppp/ppp_oe.c b/src/netif/ppp/ppp_oe.c index de78062b..dd33f8ed 100644 --- a/src/netif/ppp/ppp_oe.c +++ b/src/netif/ppp/ppp_oe.c @@ -168,8 +168,8 @@ struct { \ /* Add a 16 bit unsigned value to a buffer pointed to by PTR */ #define PPPOE_ADD_16(PTR, VAL) \ - *(PTR)++ = (VAL) / 256; \ - *(PTR)++ = (VAL) % 256 + *(PTR)++ = (u8_t)((VAL) / 256); \ + *(PTR)++ = (u8_t)((VAL) % 256) /* Add a complete PPPoE header to the buffer pointed to by PTR */ #define PPPOE_ADD_HEADER(PTR, CODE, SESS, LEN) \ @@ -184,6 +184,7 @@ struct { \ #define PPPOE_DISC_MAXPADR 2 /* retry PADR twice */ #ifdef PPPOE_SERVER +#error "PPPOE_SERVER is not yet supported under lwIP!" /* from if_spppsubr.c */ #define IFF_PASSIVE IFF_LINK0 /* wait passively for connection */ #endif @@ -236,12 +237,9 @@ static struct pppoe_softc * pppoe_find_softc_by_hunique(u8_t *, size_t, struct n static LIST_HEAD(pppoe_softc_head, pppoe_softc) pppoe_softc_list; -int pppoe_hdrlen; - void pppoe_init(void) { - pppoe_hdrlen = sizeof(struct eth_hdr) + PPPOE_HEADERLEN; LIST_INIT(&pppoe_softc_list); } @@ -437,7 +435,7 @@ pppoe_dispatch_disc_pkt(struct netif *netif, struct pbuf *pb) goto done; } if(pb->tot_len == pb->len) { - pb->tot_len = pb->len = off + plen; /* ignore trailing garbage */ + pb->tot_len = pb->len = (u16_t)off + plen; /* ignore trailing garbage */ } tag = 0; len = 0; @@ -797,16 +795,19 @@ pppoe_send_padi(struct pppoe_softc *sc) l2 = strlen(sc->sc_concentrator_name); len += 2 + 2 + l2; } + LWIP_ASSERT("sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff", + sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff); /* allocate a buffer */ - pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len, PBUF_RAM); + pb = pbuf_alloc(PBUF_LINK, (u16_t)(sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len), PBUF_RAM); if (!pb) { return ERR_MEM; } + LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len); p = (u8_t*)pb->payload + sizeof (struct eth_hdr); /* fill in pkt */ - PPPOE_ADD_HEADER(p, PPPOE_CODE_PADI, 0, len); + PPPOE_ADD_HEADER(p, PPPOE_CODE_PADI, 0, (u16_t)len); PPPOE_ADD_16(p, PPPOE_TAG_SNAME); if (sc->sc_service_name != NULL) { PPPOE_ADD_16(p, l1); @@ -1007,10 +1008,13 @@ pppoe_send_padr(struct pppoe_softc *sc) if (sc->sc_ac_cookie_len > 0) { len += 2 + 2 + sc->sc_ac_cookie_len; /* AC cookie */ } - pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len, PBUF_RAM); + LWIP_ASSERT("sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff", + sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff); + pb = pbuf_alloc(PBUF_LINK, (u16_t)(sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len), PBUF_RAM); if (!pb) { return ERR_MEM; } + LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len); p = (u8_t*)pb->payload + sizeof (struct eth_hdr); PPPOE_ADD_HEADER(p, PPPOE_CODE_PADR, 0, len); PPPOE_ADD_16(p, PPPOE_TAG_SNAME); @@ -1047,6 +1051,7 @@ pppoe_send_padt(struct netif *outgoing_if, u_int session, const u8_t *dest) if (!pb) { return ERR_MEM; } + LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len); ethhdr = (struct eth_hdr *)pb->payload; ethhdr->type = htons(ETHTYPE_PPPOEDISC); @@ -1085,6 +1090,7 @@ pppoe_send_pado(struct pppoe_softc *sc) if (!pb) { return ERR_MEM; } + LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len); p = (u8_t*)pb->payload + sizeof (struct eth_hdr); PPPOE_ADD_HEADER(p, PPPOE_CODE_PADO, 0, len); PPPOE_ADD_16(p, PPPOE_TAG_ACCOOKIE); @@ -1121,6 +1127,7 @@ pppoe_send_pads(struct pppoe_softc *sc) if (!pb) { return ERR_MEM; } + LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len); p = (u8_t*)pb->payload + sizeof (struct eth_hdr); PPPOE_ADD_HEADER(p, PPPOE_CODE_PADS, sc->sc_session, len); PPPOE_ADD_16(p, PPPOE_TAG_SNAME); diff --git a/src/netif/ppp/vj.c b/src/netif/ppp/vj.c index 7642381e..6450d4ec 100644 --- a/src/netif/ppp/vj.c +++ b/src/netif/ppp/vj.c @@ -50,7 +50,7 @@ void vj_compress_init(struct vjcompress *comp) { - register u_int i; + register u_char i; register struct cstate *tstate = comp->tstate; #if MAX_SLOTS == 0 @@ -78,21 +78,21 @@ vj_compress_init(struct vjcompress *comp) #define ENCODE(n) { \ if ((u_short)(n) >= 256) { \ *cp++ = 0; \ - cp[1] = (n); \ - cp[0] = (n) >> 8; \ + cp[1] = (u_char)(n); \ + cp[0] = (u_char)((n) >> 8); \ cp += 2; \ } else { \ - *cp++ = (n); \ + *cp++ = (u_char)(n); \ } \ } #define ENCODEZ(n) { \ if ((u_short)(n) >= 256 || (u_short)(n) == 0) { \ *cp++ = 0; \ - cp[1] = (n); \ - cp[0] = (n) >> 8; \ + cp[1] = (u_char)(n); \ + cp[0] = (u_char)((n) >> 8); \ cp += 2; \ } else { \ - *cp++ = (n); \ + *cp++ = (u_char)(n); \ } \ } @@ -380,7 +380,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) LWIP_ASSERT("pbuf_header failed\n", 0); } cp = (u_char *)pb->payload; - *cp++ = changes | NEW_C; + *cp++ = (u_char)(changes | NEW_C); *cp++ = cs->cs_id; } else { hlen -= deltaS + 3; @@ -389,10 +389,10 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) LWIP_ASSERT("pbuf_header failed\n", 0); } cp = (u_char *)pb->payload; - *cp++ = changes; + *cp++ = (u_char)changes; } - *cp++ = deltaA >> 8; - *cp++ = deltaA; + *cp++ = (u_char)(deltaA >> 8); + *cp++ = (u_char)deltaA; BCOPY(new_seq, cp, deltaS); INCR(vjs_compressed); return (TYPE_COMPRESSED_TCP); @@ -447,7 +447,7 @@ vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp) comp->flags &=~ VJF_TOSS; IPH_PROTO_SET(ip, IP_PROTO_TCP); BCOPY(ip, &cs->cs_ip, hlen); - cs->cs_hlen = hlen; + cs->cs_hlen = (u_short)hlen; INCR(vjs_uncompressedin); return 0; } @@ -570,7 +570,7 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp) #if BYTE_ORDER == LITTLE_ENDIAN tmp = n0->tot_len - vjlen + cs->cs_hlen; - IPH_LEN_SET(&cs->cs_ip, htons(tmp)); + IPH_LEN_SET(&cs->cs_ip, htons((u_short)tmp)); #else IPH_LEN_SET(&cs->cs_ip, htons(n0->tot_len - vjlen + cs->cs_hlen)); #endif