diff options
author | Brian Somers <brian@FreeBSD.org> | 1998-04-19 23:09:03 +0000 |
---|---|---|
committer | Brian Somers <brian@FreeBSD.org> | 1998-04-19 23:09:03 +0000 |
commit | fe3125a0c3fafc6542e99a1a4aa1d44787aa1e97 (patch) | |
tree | a487866605615a1435b2b094426e0d24b189aa08 | |
parent | c02f3787061a79b503feb50fefc1a6462379bf4c (diff) | |
download | src-fe3125a0c3fafc6542e99a1a4aa1d44787aa1e97.tar.gz src-fe3125a0c3fafc6542e99a1a4aa1d44787aa1e97.zip |
o Use __attribute__ (#ifdef __GNUC__) to type-check
LogPrintf() and prompt_Printf(), and fix the bits
identified as being wrong as a result.
Notes
Notes:
svn path=/cvs2svn/branches/MP/; revision=35317
-rw-r--r-- | usr.sbin/ppp/bundle.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/fsm.c | 18 | ||||
-rw-r--r-- | usr.sbin/ppp/id.c | 6 | ||||
-rw-r--r-- | usr.sbin/ppp/ipcp.c | 27 | ||||
-rw-r--r-- | usr.sbin/ppp/lcp.c | 12 | ||||
-rw-r--r-- | usr.sbin/ppp/log.h | 7 | ||||
-rw-r--r-- | usr.sbin/ppp/lqr.c | 7 | ||||
-rw-r--r-- | usr.sbin/ppp/modem.c | 8 | ||||
-rw-r--r-- | usr.sbin/ppp/prompt.h | 7 | ||||
-rw-r--r-- | usr.sbin/ppp/sig.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/slcompress.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/timer.c | 8 |
12 files changed, 58 insertions, 54 deletions
diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index ac9b19dca1a1..cfdc1bfaea67 100644 --- a/usr.sbin/ppp/bundle.c +++ b/usr.sbin/ppp/bundle.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bundle.c,v 1.1.2.53 1998/04/18 23:17:23 brian Exp $ + * $Id: bundle.c,v 1.1.2.54 1998/04/19 15:24:36 brian Exp $ */ #include <sys/types.h> @@ -744,7 +744,7 @@ failed: cmdstr, inet_ntoa(dst), strerror(rtmes.m_rtm.rtm_errno)); } LogPrintf(LogDEBUG, "wrote %d: cmd = %s, dst = %x, gateway = %x\n", - wb, cmdstr, dst.s_addr, gateway.s_addr); + wb, cmdstr, (unsigned)dst.s_addr, (unsigned)gateway.s_addr); close(s); } diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c index 8b660c1c09c8..065d7681b97e 100644 --- a/usr.sbin/ppp/fsm.c +++ b/usr.sbin/ppp/fsm.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: fsm.c,v 1.27.2.28 1998/04/16 00:25:58 brian Exp $ + * $Id: fsm.c,v 1.27.2.29 1998/04/19 15:24:41 brian Exp $ * * TODO: */ @@ -782,18 +782,17 @@ FsmRecvEchoReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) { struct lcp *lcp = fsm2lcp(fp); u_char *cp; - u_long *lp, magic; + u_int32_t magic; if (lcp) { cp = MBUF_CTOP(bp); - lp = (u_long *) cp; - magic = ntohl(*lp); + magic = ntohl(*(u_int32_t *)cp); if (magic != lcp->his_magic) { LogPrintf(LogERROR, "RecvEchoReq: his magic is bad!!\n"); /* XXX: We should send terminate request */ } if (fp->state == ST_OPENED) { - *lp = htonl(lcp->want_magic); /* Insert local magic number */ + *(u_int32_t *)cp = htonl(lcp->want_magic); /* local magic */ FsmOutput(fp, CODE_ECHOREP, lhp->id, cp, plength(bp)); } } @@ -804,19 +803,18 @@ static void FsmRecvEchoRep(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) { struct lcp *lcp = fsm2lcp(fp); - u_long *lp, magic; + u_int32_t magic; if (lcp) { - lp = (u_long *) MBUF_CTOP(bp); - magic = ntohl(*lp); + magic = ntohl(*(u_int32_t *)MBUF_CTOP(bp)); /* Tolerate echo replies with either magic number */ if (magic != 0 && magic != lcp->his_magic && magic != lcp->want_magic) { LogPrintf(LogWARN, "RecvEchoRep: Bad magic: expected 0x%08x, got: 0x%08x\n", lcp->his_magic, magic); /* - * XXX: We should send terminate request. But poor implementation may die - * as a result. + * XXX: We should send terminate request. But poor implementations may + * die as a result. */ } RecvEchoLqr(fp, bp); diff --git a/usr.sbin/ppp/id.c b/usr.sbin/ppp/id.c index 2ddb12d50072..ea277173a1ab 100644 --- a/usr.sbin/ppp/id.c +++ b/usr.sbin/ppp/id.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: id.c,v 1.6.4.4 1998/04/07 00:53:45 brian Exp $ + * $Id: id.c,v 1.6.4.5 1998/04/17 22:05:16 brian Exp $ */ #include <sys/types.h> @@ -87,7 +87,7 @@ ID0ioctl(int fd, unsigned long req, void *arg) ID0set0(); ret = ioctl(fd, req, arg); - LogPrintf(LogID0, "%d = ioctl(%d, %d, %p)\n", ret, fd, req, arg); + LogPrintf(LogID0, "%d = ioctl(%d, %lu, %p)\n", ret, fd, req, arg); ID0setuser(); return ret; } @@ -190,7 +190,7 @@ ID0login(struct utmp *ut) } login(ut); LogPrintf(LogID0, "login(\"%s\", \"%.*s\")\n", - ut->ut_line, sizeof ut->ut_name, ut->ut_name); + ut->ut_line, (int)(sizeof ut->ut_name), ut->ut_name); ID0setuser(); } diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c index 8a4455ca2943..0e6cd2f888b2 100644 --- a/usr.sbin/ppp/ipcp.c +++ b/usr.sbin/ppp/ipcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ipcp.c,v 1.50.2.38 1998/04/17 22:05:25 brian Exp $ + * $Id: ipcp.c,v 1.50.2.39 1998/04/19 03:40:59 brian Exp $ * * TODO: * o More RFC1772 backwoard compatibility @@ -722,11 +722,12 @@ static int AcceptableAddr(struct in_range *prange, struct in_addr ipaddr) { /* Is the given IP in the given range ? */ - LogPrintf(LogDEBUG, "requested = %x\n", htonl(ipaddr.s_addr)); - LogPrintf(LogDEBUG, "range = %x\n", htonl(prange->ipaddr.s_addr)); - LogPrintf(LogDEBUG, "/%x\n", htonl(prange->mask.s_addr)); - LogPrintf(LogDEBUG, "%x, %x\n", htonl(prange->ipaddr.s_addr & prange-> - mask.s_addr), htonl(ipaddr.s_addr & prange->mask.s_addr)); + LogPrintf(LogDEBUG, "requested = %x\n", (unsigned)htonl(ipaddr.s_addr)); + LogPrintf(LogDEBUG, "range = %x\n", (unsigned)htonl(prange->ipaddr.s_addr)); + LogPrintf(LogDEBUG, "/%x\n", (unsigned)htonl(prange->mask.s_addr)); + LogPrintf(LogDEBUG, "%x, %x\n", + (unsigned)htonl(prange->ipaddr.s_addr & prange->mask.s_addr), + (unsigned)htonl(ipaddr.s_addr & prange->mask.s_addr)); return (prange->ipaddr.s_addr & prange->mask.s_addr) == (ipaddr.s_addr & prange->mask.s_addr) && ipaddr.s_addr; } @@ -738,7 +739,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type, /* Deal with incoming PROTO_IPCP */ struct ipcp *ipcp = fsm2ipcp(fp); int type, length; - u_long *lp, compproto; + u_int32_t compproto; struct compreq *pcomp; struct in_addr ipaddr, dstipaddr, have_ip, dns[2], dnsnak[2]; char tbuff[100], tbuff2[100]; @@ -760,8 +761,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type, switch (type) { case TY_IPADDR: /* RFC1332 */ - lp = (u_long *) (cp + 2); - ipaddr.s_addr = *lp; + ipaddr.s_addr = *(u_int32_t *)(cp + 2); LogPrintf(LogIPCP, "%s %s\n", tbuff, inet_ntoa(ipaddr)); switch (mode_type) { @@ -834,8 +834,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type, } break; case TY_COMPPROTO: - lp = (u_long *) (cp + 2); - compproto = htonl(*lp); + compproto = htonl(*(u_int32_t *)(cp + 2)); LogPrintf(LogIPCP, "%s %s\n", tbuff, vj2asc(compproto)); switch (mode_type) { @@ -895,10 +894,8 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type, } break; case TY_IPADDRS: /* RFC1172 */ - lp = (u_long *) (cp + 2); - ipaddr.s_addr = *lp; - lp = (u_long *) (cp + 6); - dstipaddr.s_addr = *lp; + ipaddr.s_addr = *(u_int32_t *)(cp + 2); + dstipaddr.s_addr = *(u_int32_t *)(cp + 6); snprintf(tbuff2, sizeof tbuff2, "%s %s,", tbuff, inet_ntoa(ipaddr)); LogPrintf(LogIPCP, "%s %s\n", tbuff2, inet_ntoa(dstipaddr)); diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c index d2809d6f00b5..c392150236c4 100644 --- a/usr.sbin/ppp/lcp.c +++ b/usr.sbin/ppp/lcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lcp.c,v 1.55.2.41 1998/04/07 00:53:55 brian Exp $ + * $Id: lcp.c,v 1.55.2.42 1998/04/16 00:26:05 brian Exp $ * * TODO: * o Limit data field length by MRU @@ -371,7 +371,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, /* Deal with incoming PROTO_LCP */ struct lcp *lcp = fsm2lcp(fp); int type, length, sz, pos; - u_int32_t *lp, magic, accmap; + u_int32_t magic, accmap; u_short mtu, mru, *sp, proto; struct lqrreq *req; char request[20], desc[22]; @@ -421,8 +421,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, break; case TY_ACCMAP: - lp = (u_int32_t *) (cp + 2); - accmap = htonl(*lp); + accmap = htonl(*(u_int32_t *)(cp + 2)); LogPrintf(LogLCP, "%s 0x%08lx\n", request, (u_long)accmap); switch (mode_type) { @@ -543,7 +542,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, case TY_QUALPROTO: req = (struct lqrreq *)cp; - LogPrintf(LogLCP, "%s proto %x, interval %dms\n", + LogPrintf(LogLCP, "%s proto %x, interval %ldms\n", request, ntohs(req->proto), ntohl(req->period) * 10); switch (mode_type) { case MODE_REQ: @@ -567,8 +566,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, break; case TY_MAGICNUM: - lp = (u_int32_t *) (cp + 2); - magic = ntohl(*lp); + magic = ntohl(*(u_int32_t *)(cp + 2)); LogPrintf(LogLCP, "%s 0x%08lx\n", request, (u_long)magic); switch (mode_type) { diff --git a/usr.sbin/ppp/log.h b/usr.sbin/ppp/log.h index be4ac419de07..f52606b15589 100644 --- a/usr.sbin/ppp/log.h +++ b/usr.sbin/ppp/log.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: log.h,v 1.18.2.2 1998/04/03 19:25:41 brian Exp $ + * $Id: log.h,v 1.18.2.3 1998/04/07 00:54:01 brian Exp $ */ #define LogMIN (1) @@ -68,7 +68,12 @@ extern int LogIsKeptLocal(int, u_long); extern void LogOpen(const char *); extern void LogSetTun(int); extern void LogClose(void); +#ifdef __GNUC__ +extern void LogPrintf(int, const char *,...) + __attribute__ ((format (printf, 2, 3))); +#else extern void LogPrintf(int, const char *,...); +#endif extern void LogDumpBp(int, const char *, const struct mbuf *); extern void LogDumpBuff(int, const char *, const u_char *, int); extern void log_RegisterPrompt(struct prompt *); diff --git a/usr.sbin/ppp/lqr.c b/usr.sbin/ppp/lqr.c index 69bf0f68ffba..1461e6961aba 100644 --- a/usr.sbin/ppp/lqr.c +++ b/usr.sbin/ppp/lqr.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lqr.c,v 1.22.2.24 1998/04/18 01:01:24 brian Exp $ + * $Id: lqr.c,v 1.22.2.25 1998/04/19 15:24:44 brian Exp $ * * o LQR based on RFC1333 * @@ -92,7 +92,7 @@ RecvEchoLqr(struct fsm *fp, struct mbuf * bp) hdlc->lqm.echo.seq_recv = seq; } else LogPrintf(LogERROR, "RecvEchoLqr: Got sig 0x%08x, expecting 0x%08x !\n", - ntohl(lqr->signature), SIGNATURE); + (unsigned)ntohl(lqr->signature), (unsigned)SIGNATURE); } else LogPrintf(LogERROR, "RecvEchoLqr: Got packet size %d, expecting %d !\n", plength(bp), sizeof(struct echolqr)); @@ -177,7 +177,8 @@ LqrInput(struct physical *physical, struct mbuf *bp) lcp = physical->hdlc.lqm.owner; if (ntohl(lqr->MagicNumber) != physical->hdlc.lqm.owner->his_magic) LogPrintf(LogERROR, "LqrInput: magic %x != expecting %x\n", - ntohl(lqr->MagicNumber), physical->hdlc.lqm.owner->his_magic); + (unsigned)ntohl(lqr->MagicNumber), + physical->hdlc.lqm.owner->his_magic); else { /* * Remember our PeerInLQRs, then convert byte order and save diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index a719423ab8e1..773ca48c6669 100644 --- a/usr.sbin/ppp/modem.c +++ b/usr.sbin/ppp/modem.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: modem.c,v 1.77.2.51 1998/04/17 22:04:32 brian Exp $ + * $Id: modem.c,v 1.77.2.52 1998/04/19 15:24:46 brian Exp $ * * TODO: */ @@ -582,8 +582,8 @@ modem_Open(struct physical *modem, struct bundle *bundle) if (modem->dev_is_modem && !Physical_IsSync(modem)) { tcgetattr(modem->fd, &rstio); modem->ios = rstio; - LogPrintf(LogDEBUG, "modem_Open: modem (get): fd = %d, iflag = %x, " - "oflag = %x, cflag = %x\n", modem->fd, rstio.c_iflag, + LogPrintf(LogDEBUG, "modem_Open: modem (get): fd = %d, iflag = %lx, " + "oflag = %lx, cflag = %lx\n", modem->fd, rstio.c_iflag, rstio.c_oflag, rstio.c_cflag); cfmakeraw(&rstio); if (modem->cfg.rts_cts) @@ -605,7 +605,7 @@ modem_Open(struct physical *modem, struct bundle *bundle) modem->fd, modem->cfg.speed); } tcsetattr(modem->fd, TCSADRAIN, &rstio); - LogPrintf(LogDEBUG, "modem (put): iflag = %x, oflag = %x, cflag = %x\n", + LogPrintf(LogDEBUG, "modem (put): iflag = %lx, oflag = %lx, cflag = %lx\n", rstio.c_iflag, rstio.c_oflag, rstio.c_cflag); if (ioctl(modem->fd, TIOCMGET, &modem->mbits) == -1) diff --git a/usr.sbin/ppp/prompt.h b/usr.sbin/ppp/prompt.h index 34700a97aa4c..c879dfa0d375 100644 --- a/usr.sbin/ppp/prompt.h +++ b/usr.sbin/ppp/prompt.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: prompt.h,v 1.1.2.6 1998/04/07 00:54:16 brian Exp $ + * $Id: prompt.h,v 1.1.2.7 1998/04/10 13:19:19 brian Exp $ */ #define LOCAL_AUTH 0x01 @@ -69,7 +69,12 @@ struct prompt { extern struct prompt *prompt_Create(struct server *, struct bundle *, int); extern void prompt_Destroy(struct prompt *, int); extern void prompt_Required(struct prompt *); +#ifdef __GNUC__ +extern void prompt_Printf(struct prompt *, const char *, ...) + __attribute__ ((format (printf, 2, 3))); +#else extern void prompt_Printf(struct prompt *, const char *, ...); +#endif extern void prompt_vPrintf(struct prompt *, const char *, _BSD_VA_LIST_); #define PROMPT_DONT_WANT_INT 1 #define PROMPT_WANT_INT 0 diff --git a/usr.sbin/ppp/sig.c b/usr.sbin/ppp/sig.c index 3f3ff962c34f..aadb9ca4bdb7 100644 --- a/usr.sbin/ppp/sig.c +++ b/usr.sbin/ppp/sig.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: sig.c,v 1.11.2.2 1998/04/06 09:12:36 brian Exp $ + * $Id: sig.c,v 1.11.2.3 1998/04/07 00:54:18 brian Exp $ */ #include <sys/types.h> @@ -58,7 +58,7 @@ pending_signal(int sig, sig_type fn) if (sig <= 0 || sig > NSIG) { /* Oops - we must be a bit out of date (too many sigs ?) */ - LogPrintf(LogALERT, "Eeek! %s:%s: I must be out of date!\n", + LogPrintf(LogALERT, "Eeek! %s:%d: I must be out of date!\n", __FILE__, __LINE__); return signal(sig, fn); } diff --git a/usr.sbin/ppp/slcompress.c b/usr.sbin/ppp/slcompress.c index 2c4bd7a94a24..0ba264301bb3 100644 --- a/usr.sbin/ppp/slcompress.c +++ b/usr.sbin/ppp/slcompress.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: slcompress.c,v 1.15.2.6 1998/04/06 09:12:36 brian Exp $ + * $Id: slcompress.c,v 1.15.2.7 1998/04/07 00:54:19 brian Exp $ * * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989: * - Initial distribution. @@ -518,7 +518,7 @@ sl_uncompress_tcp(u_char ** bufp, int len, u_int type, } else cs->cs_ip.ip_id = htons(ntohs(cs->cs_ip.ip_id) + 1); - LogPrintf(LogDEBUG, "Uncompress: id = %04x, seq = %08x\n", + LogPrintf(LogDEBUG, "Uncompress: id = %04x, seq = %08lx\n", cs->cs_ip.ip_id, ntohl(th->th_seq)); /* diff --git a/usr.sbin/ppp/timer.c b/usr.sbin/ppp/timer.c index 8591e5f4c065..26a8b7455082 100644 --- a/usr.sbin/ppp/timer.c +++ b/usr.sbin/ppp/timer.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: timer.c,v 1.27.2.5 1998/04/17 22:04:36 brian Exp $ + * $Id: timer.c,v 1.27.2.6 1998/04/18 23:17:26 brian Exp $ * * TODO: */ @@ -90,7 +90,7 @@ StartTimer(struct pppTimer * tp) if (t) LogPrintf(LogDEBUG, "StartTimer: Inserting %s timer[%p] before %s " - "timer[%p], delta = %d\n", tp->name, tp, t->name, t, tp->rest); + "timer[%p], delta = %ld\n", tp->name, tp, t->name, t, tp->rest); else LogPrintf(LogDEBUG, "StartTimer: Inserting %s timer[%p]\n", tp->name, tp); @@ -206,7 +206,7 @@ ShowTimers(int LogLevel, struct prompt *prompt) #define SECS(val) ((val) / SECTICKS) #define HSECS(val) (((val) % SECTICKS) * 100 / SECTICKS) #define DISP \ - "%s timer[%p]: freq = %d.%02ds, next = %d.%02ds, state = %s\n", \ + "%s timer[%p]: freq = %ld.%02lds, next = %d.%02ds, state = %s\n", \ pt->name, pt, SECS(pt->load), HSECS(pt->load), SECS(rest), \ HSECS(rest), tState2Nam(pt->state) @@ -245,7 +245,7 @@ nointr_dosleep(u_int sec, u_int usec) (to.tv_sec == et.tv_sec + 1 && to.tv_usec > et.tv_usec) || to.tv_sec < st.tv_sec || (to.tv_sec == st.tv_sec && to.tv_usec < st.tv_usec)) { - LogPrintf(LogWARN, "Clock adjusted between %d and %d seconds " + LogPrintf(LogWARN, "Clock adjusted between %ld and %ld seconds " "during sleep !\n", to.tv_sec - st.tv_sec, sec + to.tv_sec - st.tv_sec); st.tv_sec = to.tv_sec; |