diff options
author | Brian Somers <brian@FreeBSD.org> | 2004-09-05 01:46:52 +0000 |
---|---|---|
committer | Brian Somers <brian@FreeBSD.org> | 2004-09-05 01:46:52 +0000 |
commit | 057f1760a8171825b260dad27502f74ed5f69faf (patch) | |
tree | fb5af1860e245ef67196527d9ba46e5c9e284bf6 /usr.sbin/ppp/ipcp.c | |
parent | 3f61368f03d40932bd1fbe095678fd44de5c8490 (diff) | |
download | src-057f1760a8171825b260dad27502f74ed5f69faf.tar.gz src-057f1760a8171825b260dad27502f74ed5f69faf.zip |
Make ppp WARNS=5 clean
Notes
Notes:
svn path=/head/; revision=134789
Diffstat (limited to 'usr.sbin/ppp/ipcp.c')
-rw-r--r-- | usr.sbin/ppp/ipcp.c | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c index 6b41f8f6653e..909484576339 100644 --- a/usr.sbin/ppp/ipcp.c +++ b/usr.sbin/ppp/ipcp.c @@ -148,7 +148,7 @@ protoname(int proto) { 131, "SECDNS" }, /* 131: Secondary DNS Server Address */ { 132, "SECNBNS" } /* 132: Secondary NBNS Server Address */ }; - int f; + unsigned f; for (f = 0; f < sizeof cftypes / sizeof *cftypes; f++) if (cftypes[f].id == proto) @@ -319,8 +319,7 @@ void ipcp_RestoreDNS(struct ipcp *ipcp) { if (ipcp->ns.resolver) { - ssize_t got; - size_t len; + ssize_t got, len; int fd; if ((fd = ID0open(_PATH_RESCONF, O_WRONLY|O_TRUNC, 0644)) != -1) { @@ -330,8 +329,8 @@ ipcp_RestoreDNS(struct ipcp *ipcp) log_Printf(LogERROR, "Failed rewriting %s: write: %s\n", _PATH_RESCONF, strerror(errno)); else - log_Printf(LogERROR, "Failed rewriting %s: wrote %lu of %lu\n", - _PATH_RESCONF, (unsigned long)got, (unsigned long)len); + log_Printf(LogERROR, "Failed rewriting %s: wrote %ld of %ld\n", + _PATH_RESCONF, (long)got, (long)len); } close(fd); } else @@ -511,7 +510,8 @@ ipcp_Setup(struct ipcp *ipcp, u_int32_t mask) struct iface *iface = ipcp->fsm.bundle->iface; struct ncpaddr ipaddr; struct in_addr peer; - int pos, n; + int pos; + unsigned n; ipcp->fsm.open_mode = 0; ipcp->ifmask.s_addr = mask == INADDR_NONE ? ipcp->cfg.netmask.s_addr : mask; @@ -605,24 +605,18 @@ numaddresses(struct in_addr mask) static int ipcp_proxyarp(struct ipcp *ipcp, - int (*proxyfun)(struct bundle *, struct in_addr, int), + int (*proxyfun)(struct bundle *, struct in_addr), const struct iface_addr *addr) { struct bundle *bundle = ipcp->fsm.bundle; struct in_addr peer, mask, ip; - int n, ret, s; + int n, ret; if (!ncpaddr_getip4(&addr->peer, &peer)) { log_Printf(LogERROR, "Oops, ipcp_proxyarp() called with unexpected addr\n"); return 0; } - if ((s = ID0socket(PF_INET, SOCK_DGRAM, 0)) == -1) { - log_Printf(LogERROR, "ipcp_proxyarp: socket: %s\n", - strerror(errno)); - return 0; - } - ret = 0; if (Enabled(bundle, OPT_PROXYALL)) { @@ -639,7 +633,7 @@ ipcp_proxyarp(struct ipcp *ipcp, } while (n) { if (!((ip.s_addr ^ peer.s_addr) & mask.s_addr)) { - if (!(ret = (*proxyfun)(bundle, ip, s))) + if (!(ret = (*proxyfun)(bundle, ip))) break; n--; } @@ -647,9 +641,7 @@ ipcp_proxyarp(struct ipcp *ipcp, } ret = !n; } else if (Enabled(bundle, OPT_PROXY)) - ret = (*proxyfun)(bundle, peer, s); - - close(s); + ret = (*proxyfun)(bundle, peer); return ret; } @@ -798,7 +790,7 @@ IpcpSendConfigReq(struct fsm *fp) } static void -IpcpSentTerminateReq(struct fsm *fp) +IpcpSentTerminateReq(struct fsm *fp __unused) { /* Term REQ just sent by FSM */ } @@ -974,7 +966,7 @@ ipcp_ValidateReq(struct ipcp *ipcp, struct in_addr ip, struct fsm_decode *dec) struct bundle *bundle = ipcp->fsm.bundle; struct iface *iface = bundle->iface; struct in_addr myaddr, peer; - int n; + unsigned n; if (iplist_isvalid(&ipcp->cfg.peer_list)) { ncprange_getip4addr(&ipcp->cfg.my_range, &myaddr); @@ -1060,7 +1052,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char *cp, u_char *end, int mode_type, gotdnsnak = 0; - while (end - cp >= sizeof(opt->hdr)) { + while (end - cp >= (int)sizeof(opt->hdr)) { if ((opt = fsm_readopt(&cp)) == NULL) break; @@ -1102,7 +1094,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char *cp, u_char *end, int mode_type, case TY_COMPPROTO: pcomp = (struct compreq *)opt->data; - compproto = (ntohs(pcomp->proto) << 16) + (pcomp->slots << 8) + + compproto = (ntohs(pcomp->proto) << 16) + ((int)pcomp->slots << 8) + pcomp->compcid; log_Printf(LogIPCP, "%s %s\n", tbuff, vj2asc(compproto)); @@ -1129,8 +1121,8 @@ IpcpDecodeConfig(struct fsm *fp, u_char *cp, u_char *end, int mode_type, break; case 6: /* RFC1332 */ if (ntohs(pcomp->proto) == PROTO_VJCOMP) { - if (pcomp->slots <= MAX_VJ_STATES - && pcomp->slots >= MIN_VJ_STATES) { + /* We know pcomp->slots' max value == MAX_VJ_STATES */ + if (pcomp->slots >= MIN_VJ_STATES) { /* Ok, we can do that */ ipcp->peer_compproto = compproto; ipcp->heis1172 = 0; @@ -1138,8 +1130,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char *cp, u_char *end, int mode_type, } else { /* Get as close as we can to what he wants */ ipcp->heis1172 = 0; - pcomp->slots = pcomp->slots < MIN_VJ_STATES ? - MIN_VJ_STATES : MAX_VJ_STATES; + pcomp->slots = MIN_VJ_STATES; nak.hdr.id = TY_COMPPROTO; nak.hdr.len = 4; memcpy(nak.data, &pcomp, 2); @@ -1165,9 +1156,8 @@ IpcpDecodeConfig(struct fsm *fp, u_char *cp, u_char *end, int mode_type, case MODE_NAK: if (ntohs(pcomp->proto) == PROTO_VJCOMP) { - if (pcomp->slots > MAX_VJ_STATES) - pcomp->slots = MAX_VJ_STATES; - else if (pcomp->slots < MIN_VJ_STATES) + /* We know pcomp->slots' max value == MAX_VJ_STATES */ + if (pcomp->slots < MIN_VJ_STATES) pcomp->slots = MIN_VJ_STATES; compproto = (ntohs(pcomp->proto) << 16) + (pcomp->slots << 8) + pcomp->compcid; |