fixed bug #43235, cleared compiler warnings when using gcc with -Wextra option

This commit is contained in:
Sylvain Rochet 2014-10-12 19:54:43 +02:00
parent ab9feb2e35
commit da19974e81
13 changed files with 84 additions and 34 deletions

View File

@ -546,6 +546,7 @@ set_permitted_number(argv)
* An Open on LCP has requested a change from Dead to Establish phase.
*/
void link_required(ppp_pcb *pcb) {
LWIP_UNUSED_ARG(pcb);
}
#if 0
@ -1003,6 +1004,7 @@ void continue_networks(ppp_pcb *pcb) {
*/
void auth_peer_fail(ppp_pcb *pcb, int protocol) {
int errcode = PPPERR_AUTHFAIL;
LWIP_UNUSED_ARG(protocol);
/*
* Authentication failure: take the link down
*/
@ -1057,8 +1059,8 @@ void auth_peer_success(ppp_pcb *pcb, int protocol, int prot_flavor, char *name,
* Save the authenticated name of the peer for later.
*/
/* FIXME: do we need that ? */
if (namelen > sizeof(pcb->peer_authname) - 1)
namelen = sizeof(pcb->peer_authname) - 1;
if (namelen > (int)sizeof(pcb->peer_authname) - 1)
namelen = (int)sizeof(pcb->peer_authname) - 1;
MEMCPY(pcb->peer_authname, name, namelen);
pcb->peer_authname[namelen] = 0;
#if 0 /* UNUSED */
@ -1082,6 +1084,7 @@ void auth_peer_success(ppp_pcb *pcb, int protocol, int prot_flavor, char *name,
*/
void auth_withpeer_fail(ppp_pcb *pcb, int protocol) {
int errcode = PPPERR_AUTHFAIL;
LWIP_UNUSED_ARG(protocol);
/*
* We've failed to authenticate ourselves to our peer.
*
@ -1162,6 +1165,7 @@ void np_up(ppp_pcb *pcb, int proto) {
#if PPP_IDLETIMELIMIT
int tlim;
#endif /* PPP_IDLETIMELIMIT */
LWIP_UNUSED_ARG(proto);
if (pcb->num_np_up == 0) {
/*
@ -1209,6 +1213,7 @@ void np_up(ppp_pcb *pcb, int proto) {
* np_down - a network protocol has gone down.
*/
void np_down(ppp_pcb *pcb, int proto) {
LWIP_UNUSED_ARG(proto);
if (--pcb->num_np_up == 0) {
#if PPP_IDLETIMELIMIT
UNTIMEOUT(check_idle, (void*)pcb);
@ -1227,6 +1232,7 @@ void np_down(ppp_pcb *pcb, int proto) {
* np_finished - a network protocol has finished using the link.
*/
void np_finished(ppp_pcb *pcb, int proto) {
LWIP_UNUSED_ARG(proto);
if (--pcb->num_np_open <= 0) {
/* no further use for the link: shut up shop. */
lcp_close(pcb, "No network protocols running");

View File

@ -70,6 +70,7 @@ static int chap_md5_verify_response(int id, char *name,
unsigned char idbyte = id;
unsigned char hash[MD5_HASH_SIZE];
int challenge_len, response_len;
LWIP_UNUSED_ARG(name);
challenge_len = *challenge++;
response_len = *response++;
@ -98,6 +99,8 @@ static void chap_md5_make_response(unsigned char *response, int id, char *our_na
md5_context ctx;
unsigned char idbyte = id;
int challenge_len = *challenge++;
LWIP_UNUSED_ARG(our_name);
LWIP_UNUSED_ARG(private);
md5_starts(&ctx);
md5_update(&ctx, &idbyte, 1);

View File

@ -106,7 +106,7 @@ static int chap_print_pkt(unsigned char *p, int plen,
#endif /* PRINTPKT_SUPPORT */
/* List of digest types that we know about */
const static struct chap_digest_type* const chap_digests[] = {
static const struct chap_digest_type* const chap_digests[] = {
&md5_digest,
#if MSCHAP_SUPPORT
&chapms_digest,
@ -409,7 +409,11 @@ static int chap_verify_response(char *name, char *ourname, int id,
ppp_error("No CHAP secret found for authenticating %q", name);
return 0;
}
#endif
#else
/* only here to clean compiler warnings */
LWIP_UNUSED_ARG(ourname);
secret_len = 0;
#endif /* 0 */
ok = digest->verify_response(id, name, secret, secret_len, challenge,
response, message, message_space);
memset(secret, 0, sizeof(secret));
@ -486,6 +490,7 @@ static void chap_respond(ppp_pcb *pcb, int id,
static void chap_handle_status(ppp_pcb *pcb, int code, int id,
unsigned char *pkt, int len) {
const char *msg = NULL;
LWIP_UNUSED_ARG(id);
if ((pcb->chap_client.flags & (AUTH_DONE|AUTH_STARTED|LOWERUP))
!= (AUTH_STARTED|LOWERUP))
@ -590,7 +595,7 @@ static int chap_print_pkt(unsigned char *p, int plen,
if (len < CHAP_HDRLEN || len > plen)
return 0;
if (code >= 1 && code <= sizeof(chap_code_names) / sizeof(char *))
if (code >= 1 && code <= (int)sizeof(chap_code_names) / (int)sizeof(char *))
printer(arg, " %s", chap_code_names[code-1]);
else
printer(arg, " code=0x%x", code);

View File

@ -208,6 +208,8 @@ static int chapms_verify_response(int id, char *name,
unsigned char md[MS_CHAP_RESPONSE_LEN];
int diff;
int challenge_len, response_len;
LWIP_UNUSED_ARG(id);
LWIP_UNUSED_ARG(name);
challenge_len = *challenge++; /* skip length, is 8 */
response_len = *response++;
@ -254,6 +256,7 @@ static int chapms2_verify_response(int id, char *name,
unsigned char md[MS_CHAP2_RESPONSE_LEN];
char saresponse[MS_AUTH_RESPONSE_LENGTH+1];
int challenge_len, response_len;
LWIP_UNUSED_ARG(id);
challenge_len = *challenge++; /* skip length, is 16 */
response_len = *response++;
@ -326,6 +329,9 @@ static int chapms2_verify_response(int id, char *name,
static void chapms_make_response(unsigned char *response, int id, char *our_name,
unsigned char *challenge, char *secret, int secret_len,
unsigned char *private) {
LWIP_UNUSED_ARG(id);
LWIP_UNUSED_ARG(our_name);
LWIP_UNUSED_ARG(private);
challenge++; /* skip length, should be 8 */
*response++ = MS_CHAP_RESPONSE_LEN;
ChapMS(challenge, secret, secret_len, response);
@ -334,6 +340,7 @@ static void chapms_make_response(unsigned char *response, int id, char *our_name
static void chapms2_make_response(unsigned char *response, int id, char *our_name,
unsigned char *challenge, char *secret, int secret_len,
unsigned char *private) {
LWIP_UNUSED_ARG(id);
challenge++; /* skip length, should be 16 */
*response++ = MS_CHAP2_RESPONSE_LEN;
ChapMS2(challenge,
@ -608,7 +615,7 @@ void GenerateAuthenticatorResponse(u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
sha1_finish(&sha1Context, Digest);
/* Convert to ASCII hex string. */
for (i = 0; i < LWIP_MAX((MS_AUTH_RESPONSE_LENGTH / 2), sizeof(Digest)); i++)
for (i = 0; i < LWIP_MAX((MS_AUTH_RESPONSE_LENGTH / 2), (int)sizeof(Digest)); i++)
sprintf((char *)&authResponse[i * 2], "%02X", Digest[i]);
}
@ -821,6 +828,7 @@ void ChapMS2(u_char *rchallenge, u_char *PeerChallenge,
/* ARGSUSED */
u_char *p = &response[MS_CHAP2_PEER_CHALLENGE];
int i;
LWIP_UNUSED_ARG(authenticator);
BZERO(response, MS_CHAP2_RESPONSE_LEN);

View File

@ -2046,6 +2046,8 @@ static void eap_response(ppp_pcb *pcb, u_char *inp, int id, int len) {
* eap_success - Receive EAP Success message (client mode).
*/
static void eap_success(ppp_pcb *pcb, u_char *inp, int id, int len) {
LWIP_UNUSED_ARG(id);
if (pcb->eap.es_client.ea_state != eapOpen && !eap_client_active(pcb)) {
ppp_dbglog("EAP unexpected success message in state %s (%d)",
eap_state_name(pcb->eap.es_client.ea_state),
@ -2070,6 +2072,8 @@ static void eap_success(ppp_pcb *pcb, u_char *inp, int id, int len) {
* eap_failure - Receive EAP Failure message (client mode).
*/
static void eap_failure(ppp_pcb *pcb, u_char *inp, int id, int len) {
LWIP_UNUSED_ARG(id);
if (!eap_client_active(pcb)) {
ppp_dbglog("EAP unexpected failure message in state %s (%d)",
eap_state_name(pcb->eap.es_client.ea_state),
@ -2173,7 +2177,7 @@ static int eap_printpkt(u_char *inp, int inlen, void (*printer) (void *, char *,
if (len < EAP_HEADERLEN || len > inlen)
return (0);
if (code >= 1 && code <= sizeof(eap_codenames) / sizeof(char *))
if (code >= 1 && code <= (int)sizeof(eap_codenames) / (int)sizeof(char *))
printer(arg, " %s", eap_codenames[code-1]);
else
printer(arg, " code=0x%x", code);
@ -2188,7 +2192,7 @@ static int eap_printpkt(u_char *inp, int inlen, void (*printer) (void *, char *,
GETCHAR(rtype, inp);
len--;
if (rtype >= 1 &&
rtype <= sizeof (eap_typenames) / sizeof (char *))
rtype <= (int)sizeof (eap_typenames) / (int)sizeof (char *))
printer(arg, " %s", eap_typenames[rtype-1]);
else
printer(arg, " type=0x%x", rtype);
@ -2283,7 +2287,7 @@ static int eap_printpkt(u_char *inp, int inlen, void (*printer) (void *, char *,
break;
case EAPSRP_SVALIDATOR:
if (len < sizeof (u32_t))
if (len < (int)sizeof (u32_t))
break;
GETLONG(uval, inp);
len -= sizeof (u32_t);
@ -2323,7 +2327,7 @@ static int eap_printpkt(u_char *inp, int inlen, void (*printer) (void *, char *,
GETCHAR(rtype, inp);
len--;
if (rtype >= 1 &&
rtype <= sizeof (eap_typenames) / sizeof (char *))
rtype <= (int)sizeof (eap_typenames) / (int)sizeof (char *))
printer(arg, " %s", eap_typenames[rtype-1]);
else
printer(arg, " type=0x%x", rtype);
@ -2347,7 +2351,7 @@ static int eap_printpkt(u_char *inp, int inlen, void (*printer) (void *, char *,
len--;
printer(arg, " <Suggested-type %02X", rtype);
if (rtype >= 1 &&
rtype < sizeof (eap_typenames) / sizeof (char *))
rtype < (int)sizeof (eap_typenames) / (int)sizeof (char *))
printer(arg, " (%s)", eap_typenames[rtype-1]);
printer(arg, ">");
break;
@ -2389,7 +2393,7 @@ static int eap_printpkt(u_char *inp, int inlen, void (*printer) (void *, char *,
break;
case EAPSRP_CVALIDATOR:
if (len < sizeof (u32_t))
if (len < (int)sizeof (u32_t))
break;
GETLONG(uval, inp);
len -= sizeof (u32_t);

View File

@ -2041,6 +2041,7 @@ static void ipcp_down(fsm *f) {
* proxy arp entries, etc.
*/
static void ipcp_clear_addrs(ppp_pcb *pcb, u32_t ouraddr, u32_t hisaddr, u8_t replacedefaultroute) {
LWIP_UNUSED_ARG(replacedefaultroute);
if (pcb->proxy_arp_set) {
cifproxyarp(pcb, hisaddr);
@ -2113,7 +2114,7 @@ static int ipcp_printpkt(u_char *p, int plen,
if (len < HEADERLEN || len > plen)
return 0;
if (code >= 1 && code <= sizeof(ipcp_codenames) / sizeof(char *))
if (code >= 1 && code <= (int)sizeof(ipcp_codenames) / (int)sizeof(char *))
printer(arg, " %s", ipcp_codenames[code-1]);
else
printer(arg, " code=0x%x", code);

View File

@ -44,30 +44,30 @@
Alain.Durand@imag.fr, IMAG,
Jean-Luc.Richier@imag.fr, IMAG-LSR.
Ce travail a é fait au sein du GIE DYADE (Groupement d'Intérêt
Économique ayant pour membres BULL S.A. et l'INRIA).
Ce travail a <EFBFBD>t<EFBFBD> fait au sein du GIE DYADE (Groupement d'Int<EFBFBD>r<EFBFBD>t
<EFBFBD>conomique ayant pour membres BULL S.A. et l'INRIA).
Ce logiciel informatique est disponible aux conditions
usuelles dans la recherche, c'est-à-dire qu'il peut
être utilisé, copié, modifié, distribué à l'unique
condition que ce texte soit conservé afin que
usuelles dans la recherche, c'est-<EFBFBD>-dire qu'il peut
<EFBFBD>tre utilis<EFBFBD>, copi<EFBFBD>, modifi<EFBFBD>, distribu<EFBFBD> <EFBFBD> l'unique
condition que ce texte soit conserv<EFBFBD> afin que
l'origine de ce logiciel soit reconnue.
Le nom de l'Institut National de Recherche en Informatique
et en Automatique (INRIA), de l'IMAG, ou d'une personne morale
ou physique ayant participé à l'élaboration de ce logiciel ne peut
être utilisé sans son accord préalable explicite.
ou physique ayant particip<EFBFBD> <EFBFBD> l'<EFBFBD>laboration de ce logiciel ne peut
<EFBFBD>tre utilis<EFBFBD> sans son accord pr<EFBFBD>alable explicite.
Ce logiciel est fourni tel quel sans aucune garantie,
support ou responsabilité d'aucune sorte.
Ce logiciel est dérivé de sources d'origine
support ou responsabilit<EFBFBD> d'aucune sorte.
Ce logiciel est d<EFBFBD>riv<EFBFBD> de sources d'origine
"University of California at Berkeley" et
"Digital Equipment Corporation" couvertes par des copyrights.
L'Institut d'Informatique et de Mathématiques Appliquées de Grenoble (IMAG)
est une fédération d'unités mixtes de recherche du CNRS, de l'Institut National
Polytechnique de Grenoble et de l'Université Joseph Fourier regroupant
sept laboratoires dont le laboratoire Logiciels, Systèmes, seaux (LSR).
L'Institut d'Informatique et de Math<EFBFBD>matiques Appliqu<EFBFBD>es de Grenoble (IMAG)
est une f<EFBFBD>d<EFBFBD>ration d'unit<EFBFBD>s mixtes de recherche du CNRS, de l'Institut National
Polytechnique de Grenoble et de l'Universit<EFBFBD> Joseph Fourier regroupant
sept laboratoires dont le laboratoire Logiciels, Syst<EFBFBD>mes, R<EFBFBD>seaux (LSR).
This work has been done in the context of GIE DYADE (joint R & D venture
between BULL S.A. and INRIA).
@ -1396,7 +1396,7 @@ static int ipv6cp_printpkt(u_char *p, int plen,
if (len < HEADERLEN || len > plen)
return 0;
if (code >= 1 && code <= sizeof(ipv6cp_codenames) / sizeof(char *))
if (code >= 1 && code <= (int)sizeof(ipv6cp_codenames) / (int)sizeof(char *))
printer(arg, " %s", ipv6cp_codenames[code-1]);
else
printer(arg, " code=0x%x", code);

View File

@ -1382,6 +1382,8 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
try_.mrru = cishort;
);
}
#else /* HAVE_MULTILINK */
LWIP_UNUSED_ARG(treat_as_reject);
#endif /* HAVE_MULTILINK */
/*
@ -2332,7 +2334,7 @@ static int lcp_printpkt(u_char *p, int plen,
if (len < HEADERLEN || len > plen)
return 0;
if (code >= 1 && code <= sizeof(lcp_codenames) / sizeof(char *))
if (code >= 1 && code <= (int)sizeof(lcp_codenames) / (int)sizeof(char *))
printer(arg, " %s", lcp_codenames[code-1]);
else
printer(arg, " code=0x%x", code);
@ -2617,6 +2619,7 @@ static void lcp_received_echo_reply(fsm *f, int id, u_char *inp, int len) {
ppp_pcb *pcb = f->pcb;
lcp_options *go = &pcb->lcp_gotoptions;
u32_t magic;
LWIP_UNUSED_ARG(id);
/* Check the magic number - don't count replies from ourselves. */
if (len < 4) {

View File

@ -1925,6 +1925,7 @@ static void ppp_over_l2tp_open(ppp_pcb *pcb) {
#endif /* PPPOL2TP_SUPPORT */
void ppp_link_down(ppp_pcb *pcb) {
LWIP_UNUSED_ARG(pcb); /* necessary if PPPDEBUG is defined to an empty function */
PPPDEBUG(LOG_DEBUG, ("ppp_link_down: unit %d\n", pcb->num));
}
@ -2009,6 +2010,7 @@ int ppp_send_config(ppp_pcb *pcb, int mtu, u32_t accm, int pcomp, int accomp) {
#if PPPOS_SUPPORT
int i;
#endif /* PPPOS_SUPPORT */
LWIP_UNUSED_ARG(mtu);
/* pcb->mtu = mtu; -- set correctly with netif_set_mtu */
pcb->pcomp = pcomp;

View File

@ -313,7 +313,7 @@ pppoe_disc_input(struct netif *netif, struct pbuf *pb)
hunique_len = 0;
#endif
session = 0;
if (pb->len - off < PPPOE_HEADERLEN) {
if (pb->len - off < (u16_t)PPPOE_HEADERLEN) {
PPPDEBUG(LOG_DEBUG, ("pppoe: packet too short: %d\n", pb->len));
goto done;
}

View File

@ -189,6 +189,7 @@ static void pppol2tp_input(void *arg, struct udp_pcb *pcb, struct pbuf *p, struc
pppol2tp_pcb *l2tp = (pppol2tp_pcb*)arg;
u16_t hflags, hlen, len=0, tunnel_id=0, session_id=0, ns=0, nr=0, offset=0;
u8_t *inp;
LWIP_UNUSED_ARG(pcb);
if (l2tp->phase < PPPOL2TP_STATE_SCCRQ_SENT) {
goto free_and_return;
@ -324,6 +325,10 @@ static void pppol2tp_dispatch_control_packet(pppol2tp_pcb *l2tp, struct ip_addr
u8_t md5_hash[16];
u8_t challenge_id = 0;
#endif /* PPPOL2TP_AUTH_SUPPORT */
LWIP_UNUSED_ARG(addr);
LWIP_UNUSED_ARG(len);
LWIP_UNUSED_ARG(tunnel_id);
LWIP_UNUSED_ARG(session_id);
l2tp->peer_nr = nr;
l2tp->peer_ns = ns;

View File

@ -357,7 +357,10 @@ static void upap_input(ppp_pcb *pcb, u_char *inpacket, int l) {
*/
static void upap_rauthreq(ppp_pcb *pcb, u_char *inp, int id, int len) {
u_char ruserlen, rpasswdlen;
char *ruser, *rpasswd;
char *ruser;
#if 0
char *rpasswd;
#endif
char rhostname[256];
int retcode;
char *msg;
@ -401,12 +404,12 @@ static void upap_rauthreq(ppp_pcb *pcb, u_char *inp, int id, int len) {
}
/* FIXME: we need a way to check peer secret */
#if 0
rpasswd = (char *) inp;
/*
* Check the username and password given.
*/
#if 0
retcode = check_passwd(pcb->upap.us_unit, ruser, ruserlen, rpasswd,
rpasswdlen, &msg);
BZERO(rpasswd, rpasswdlen);
@ -423,11 +426,17 @@ static void upap_rauthreq(ppp_pcb *pcb, u_char *inp, int id, int len) {
warn("calling number %q is not authorized", remote_number);
}
}
#endif
msglen = strlen(msg);
if (msglen > 255)
msglen = 255;
#else
/* only here to clean compiler warnings */
retcode = UPAP_AUTHNAK;
msg = NULL;
msglen = 0;
#endif /* 0 */
upap_sresp(pcb, retcode, id, msg, msglen);
/* Null terminate and clean remote name. */
@ -454,6 +463,7 @@ static void upap_rauthreq(ppp_pcb *pcb, u_char *inp, int id, int len) {
static void upap_rauthack(ppp_pcb *pcb, u_char *inp, int id, int len) {
u_char msglen;
char *msg;
LWIP_UNUSED_ARG(id);
if (pcb->upap.us_clientstate != UPAPCS_AUTHREQ) /* XXX */
return;
@ -488,6 +498,7 @@ static void upap_rauthack(ppp_pcb *pcb, u_char *inp, int id, int len) {
static void upap_rauthnak(ppp_pcb *pcb, u_char *inp, int id, int len) {
u_char msglen;
char *msg;
LWIP_UNUSED_ARG(id);
if (pcb->upap.us_clientstate != UPAPCS_AUTHREQ) /* XXX */
return;
@ -608,7 +619,7 @@ static int upap_printpkt(u_char *p, int plen, void (*printer) (void *, char *, .
if (len < UPAP_HEADERLEN || len > plen)
return 0;
if (code >= 1 && code <= sizeof(upap_codenames) / sizeof(char *))
if (code >= 1 && code <= (int)sizeof(upap_codenames) / (int)sizeof(char *))
printer(arg, " %s", upap_codenames[code-1]);
else
printer(arg, " code=0x%x", code);

View File

@ -209,7 +209,7 @@ int ppp_vslprintf(char *buf, int buflen, char *fmt, va_list args) {
val = va_arg(args, long);
if ((long)val < 0) {
neg = 1;
val = -val;
val = (unsigned long)-val;
}
base = 10;
break;
@ -607,6 +607,8 @@ static void ppp_logit(int level, char *fmt, va_list args) {
}
static void ppp_log_write(int level, char *buf) {
LWIP_UNUSED_ARG(level); /* necessary if PPPDEBUG is defined to an empty function */
LWIP_UNUSED_ARG(buf);
PPPDEBUG(level, ("%s\n", buf) );
#if 0
if (log_to_fd >= 0 && (level != LOG_DEBUG || debug)) {