diff options
author | brian <brian@cvs.openbsd.org> | 1997-12-24 09:30:54 +0000 |
---|---|---|
committer | brian <brian@cvs.openbsd.org> | 1997-12-24 09:30:54 +0000 |
commit | 680c56f9b0e96bdf2645460ef3e71d6ec165ad9a (patch) | |
tree | af433d7193d7f057336d40f4866f865a81daca1a /usr.sbin | |
parent | ee509eb41ffd3386cd990df961c005dd18d3d418 (diff) |
Cosmetic (style):
sizeof(var) -> sizeof var
sizeof type -> sizeof(type)
Suggested by: J Wunsch <j@uriah.heep.sax.de>
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ppp/arp.c | 14 | ||||
-rw-r--r-- | usr.sbin/ppp/auth.c | 22 | ||||
-rw-r--r-- | usr.sbin/ppp/ccp.c | 8 | ||||
-rw-r--r-- | usr.sbin/ppp/chap.c | 8 | ||||
-rw-r--r-- | usr.sbin/ppp/chap_ms.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/chat.c | 16 | ||||
-rw-r--r-- | usr.sbin/ppp/command.c | 46 | ||||
-rw-r--r-- | usr.sbin/ppp/defs.c | 6 | ||||
-rw-r--r-- | usr.sbin/ppp/filter.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/fsm.c | 8 | ||||
-rw-r--r-- | usr.sbin/ppp/hdlc.c | 6 | ||||
-rw-r--r-- | usr.sbin/ppp/ip.c | 15 | ||||
-rw-r--r-- | usr.sbin/ppp/ipcp.c | 30 | ||||
-rw-r--r-- | usr.sbin/ppp/iplist.c | 10 | ||||
-rw-r--r-- | usr.sbin/ppp/lcp.c | 10 | ||||
-rw-r--r-- | usr.sbin/ppp/log.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/main.c | 16 | ||||
-rw-r--r-- | usr.sbin/ppp/modem.c | 28 | ||||
-rw-r--r-- | usr.sbin/ppp/os.c | 26 | ||||
-rw-r--r-- | usr.sbin/ppp/pap.c | 8 | ||||
-rw-r--r-- | usr.sbin/ppp/route.c | 22 | ||||
-rw-r--r-- | usr.sbin/ppp/server.c | 6 | ||||
-rw-r--r-- | usr.sbin/ppp/slcompress.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/systems.c | 6 |
24 files changed, 165 insertions, 162 deletions
diff --git a/usr.sbin/ppp/arp.c b/usr.sbin/ppp/arp.c index 4fd52304bbf..339dbbaf3dc 100644 --- a/usr.sbin/ppp/arp.c +++ b/usr.sbin/ppp/arp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: arp.c,v 1.2 1997/12/23 22:38:00 brian Exp $ + * $Id: arp.c,v 1.3 1997/12/24 09:30:20 brian Exp $ * */ @@ -90,7 +90,7 @@ sifproxyarp(int unit, u_long hisaddr) * Get the hardware address of an interface on the same subnet as our local * address. */ - memset(&arpmsg, 0, sizeof(arpmsg)); + memset(&arpmsg, 0, sizeof arpmsg); if (!get_ether_addr(unit, hisaddr, &arpmsg.hwa)) { LogPrintf(LogERROR, "Cannot determine ethernet address for proxy ARP\n"); return 0; @@ -168,7 +168,7 @@ sifproxyarp(int unit, u_long hisaddr) char space[128]; } dls; - memset(&arpreq, '\0', sizeof(arpreq)); + memset(&arpreq, '\0', sizeof arpreq); /* * Get the hardware address of an interface on the same subnet as our local @@ -199,7 +199,7 @@ cifproxyarp(int unit, u_long hisaddr) { struct arpreq arpreq; - memset(&arpreq, '\0', sizeof(arpreq)); + memset(&arpreq, '\0', sizeof arpreq); SET_SA_FAMILY(arpreq.arp_pa, AF_INET); ((struct sockaddr_in *) & arpreq.arp_pa)->sin_addr.s_addr = hisaddr; if (ID0ioctl(unit, SIOCDARP, (caddr_t) & arpreq) < 0) { @@ -228,7 +228,7 @@ get_ether_addr(int s, u_long ipaddr, struct sockaddr_dl *hwaddr) struct ifconf ifc; struct ifreq ifs[MAX_IFS]; - ifc.ifc_len = sizeof(ifs); + ifc.ifc_len = sizeof ifs; ifc.ifc_req = ifs; if (ioctl(s, SIOCGIFCONF, &ifc) < 0) { LogPrintf(LogERROR, "get_ether_addr: ioctl(SIOCGIFCONF): %s\n", @@ -244,8 +244,8 @@ get_ether_addr(int s, u_long ipaddr, struct sockaddr_dl *hwaddr) for (ifr = ifc.ifc_req; ifr < ifend;) { if (ifr->ifr_addr.sa_family == AF_INET) { ina = ((struct sockaddr_in *) & ifr->ifr_addr)->sin_addr.s_addr; - strncpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name) - 1); - ifreq.ifr_name[sizeof(ifreq.ifr_name) - 1] = '\0'; + strncpy(ifreq.ifr_name, ifr->ifr_name, sizeof ifreq.ifr_name - 1); + ifreq.ifr_name[sizeof ifreq.ifr_name - 1] = '\0'; /* * Check that the interface is up, and not point-to-point or loopback. diff --git a/usr.sbin/ppp/auth.c b/usr.sbin/ppp/auth.c index c3a2b055e24..dcc9d40b644 100644 --- a/usr.sbin/ppp/auth.c +++ b/usr.sbin/ppp/auth.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: auth.c,v 1.1 1997/11/23 20:27:33 brian Exp $ + * $Id: auth.c,v 1.2 1997/12/24 09:30:22 brian Exp $ * * TODO: * o Implement check against with registered IP addresses. @@ -79,11 +79,11 @@ LocalAuthValidate(const char *fname, const char *system, const char *key) fp = OpenSecret(fname); if (fp == NULL) return (rc); - while (fgets(buff, sizeof(buff), fp)) { + while (fgets(buff, sizeof buff, fp)) { if (buff[0] == '#') continue; buff[strlen(buff) - 1] = 0; - memset(vector, '\0', sizeof(vector)); + memset(vector, '\0', sizeof vector); n = MakeArgs(buff, vector, VECSIZE(vector)); if (n < 1) continue; @@ -113,19 +113,19 @@ AuthValidate(const char *fname, const char *system, const char *key) fp = OpenSecret(fname); if (fp == NULL) return (0); - while (fgets(buff, sizeof(buff), fp)) { + while (fgets(buff, sizeof buff, fp)) { if (buff[0] == '#') continue; buff[strlen(buff) - 1] = 0; - memset(vector, '\0', sizeof(vector)); + memset(vector, '\0', sizeof vector); n = MakeArgs(buff, vector, VECSIZE(vector)); if (n < 2) continue; if (strcmp(vector[0], system) == 0) { - ExpandString(vector[1], passwd, sizeof(passwd), 0); + ExpandString(vector[1], passwd, sizeof passwd, 0); if (strcmp(passwd, key) == 0) { CloseSecret(fp); - memset(&DefHisAddress, '\0', sizeof(DefHisAddress)); + memset(&DefHisAddress, '\0', sizeof DefHisAddress); n -= 2; if (n > 0) { if (ParseAddr(n--, (char const *const *)(vector+2), @@ -156,18 +156,18 @@ AuthGetSecret(const char *fname, const char *system, int len, int setaddr) fp = OpenSecret(fname); if (fp == NULL) return (NULL); - while (fgets(buff, sizeof(buff), fp)) { + while (fgets(buff, sizeof buff, fp)) { if (buff[0] == '#') continue; buff[strlen(buff) - 1] = 0; - memset(vector, '\0', sizeof(vector)); + memset(vector, '\0', sizeof vector); n = MakeArgs(buff, vector, VECSIZE(vector)); if (n < 2) continue; if (strlen(vector[0]) == len && strncmp(vector[0], system, len) == 0) { - ExpandString(vector[1], passwd, sizeof(passwd), 0); + ExpandString(vector[1], passwd, sizeof passwd, 0); if (setaddr) { - memset(&DefHisAddress, '\0', sizeof(DefHisAddress)); + memset(&DefHisAddress, '\0', sizeof DefHisAddress); } n -= 2; if (n > 0 && setaddr) { diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c index 16d69354c18..903c74f26e5 100644 --- a/usr.sbin/ppp/ccp.c +++ b/usr.sbin/ppp/ccp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ccp.c,v 1.5 1997/12/17 21:17:59 brian Exp $ + * $Id: ccp.c,v 1.6 1997/12/24 09:30:23 brian Exp $ * * TODO: * o Support other compression protocols @@ -100,7 +100,7 @@ static char const *cftypes[] = { "DEFLATE", /* 26: Deflate (rfc1979) */ }; -#define NCFTYPES (sizeof(cftypes)/sizeof(char *)) +#define NCFTYPES (sizeof cftypes/sizeof cftypes[0]) static const char * protoname(int proto) @@ -119,7 +119,7 @@ static const struct ccp_algorithm *algorithm[] = { static int in_algorithm = -1; static int out_algorithm = -1; -#define NALGORITHMS (sizeof(algorithm)/sizeof(algorithm[0])) +#define NALGORITHMS (sizeof algorithm/sizeof algorithm[0]) int ReportCcpStatus(struct cmdargs const *arg) @@ -138,7 +138,7 @@ ReportCcpStatus(struct cmdargs const *arg) static void ccpstateInit(void) { - memset(&CcpInfo, '\0', sizeof(struct ccpstate)); + memset(&CcpInfo, '\0', sizeof CcpInfo); CcpInfo.his_proto = CcpInfo.my_proto = -1; if (in_algorithm >= 0 && in_algorithm < NALGORITHMS) { (*algorithm[in_algorithm]->i.Term)(); diff --git a/usr.sbin/ppp/chap.c b/usr.sbin/ppp/chap.c index c42baa1c869..3187b66b37b 100644 --- a/usr.sbin/ppp/chap.c +++ b/usr.sbin/ppp/chap.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: chap.c,v 1.2 1997/12/07 23:55:06 brian Exp $ + * $Id: chap.c,v 1.3 1997/12/24 09:30:24 brian Exp $ * * TODO: */ @@ -230,10 +230,10 @@ RecvChapTalk(struct fsmheader *chp, struct mbuf *bp) VarBaseDevice); else { struct utmp ut; - memset(&ut, 0, sizeof(ut)); + memset(&ut, 0, sizeof ut); time(&ut.ut_time); - strncpy(ut.ut_name, name, sizeof(ut.ut_name)-1); - strncpy(ut.ut_line, VarBaseDevice, sizeof(ut.ut_line)-1); + strncpy(ut.ut_name, name, sizeof ut.ut_name - 1); + strncpy(ut.ut_line, VarBaseDevice, sizeof ut.ut_line - 1); if (logout(ut.ut_line)) logwtmp(ut.ut_line, "", ""); login(&ut); diff --git a/usr.sbin/ppp/chap_ms.c b/usr.sbin/ppp/chap_ms.c index 370bd94c06f..6ea4bdb0138 100644 --- a/usr.sbin/ppp/chap_ms.c +++ b/usr.sbin/ppp/chap_ms.c @@ -19,7 +19,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: chap_ms.c,v 1.1 1997/11/23 20:27:33 brian Exp $ + * $Id: chap_ms.c,v 1.2 1997/12/24 09:30:25 brian Exp $ * */ @@ -53,7 +53,7 @@ ChallengeResponse(u_char *challenge, u_char *pwHash, u_char *response) { char ZPasswordHash[21]; - memset(ZPasswordHash, '\0', sizeof(ZPasswordHash)); + memset(ZPasswordHash, '\0', sizeof ZPasswordHash); memcpy(ZPasswordHash, pwHash, 16); DesEncrypt(challenge, ZPasswordHash + 0, response + 0); diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c index dcc10b607c0..aa202db904b 100644 --- a/usr.sbin/ppp/chat.c +++ b/usr.sbin/ppp/chat.c @@ -18,7 +18,7 @@ * Columbus, OH 43221 * (614)451-1883 * - * $Id: chat.c,v 1.3 1997/12/23 22:38:01 brian Exp $ + * $Id: chat.c,v 1.4 1997/12/24 09:30:26 brian Exp $ * * TODO: * o Support more UUCP compatible control sequences. @@ -186,8 +186,8 @@ ExpandString(const char *str, char *result, int reslen, int sendmode) case 'T': if (VarAltPhone == NULL) { if (VarNextPhone == NULL) { - strncpy(VarPhoneCopy, VarPhoneList, sizeof(VarPhoneCopy) - 1); - VarPhoneCopy[sizeof(VarPhoneCopy) - 1] = '\0'; + strncpy(VarPhoneCopy, VarPhoneList, sizeof VarPhoneCopy - 1); + VarPhoneCopy[sizeof VarPhoneCopy - 1] = '\0'; VarNextPhone = VarPhoneCopy; } VarAltPhone = strsep(&VarNextPhone, ":"); @@ -292,7 +292,7 @@ WaitforString(const char *estr) omask = sigblock(sigmask(SIGALRM)); #endif clear_log(); - ExpandString(estr, buff, sizeof(buff), 0); + ExpandString(estr, buff, sizeof buff, 0); LogPrintf(LogCHAT, "Wait for (%d): %s --> %s\n", TimeoutSec, estr, buff); str = buff; inp = inbuff; @@ -489,7 +489,7 @@ SendString(const char *str) if (abort_next) { abort_next = 0; - ExpandString(str, buff, sizeof(buff), 0); + ExpandString(str, buff, sizeof buff, 0); AbortStrings[numaborts++] = strdup(buff); } else if (timeout_next) { timeout_next = 0; @@ -498,10 +498,10 @@ SendString(const char *str) TimeoutSec = 30; } else { if (*str == '!') { - ExpandString(str + 1, buff + 2, sizeof(buff) - 2, 0); + ExpandString(str + 1, buff + 2, sizeof buff - 2, 0); ExecStr(buff + 2, buff + 2); } else { - ExpandString(str, buff + 2, sizeof(buff) - 2, 1); + ExpandString(str, buff + 2, sizeof buff - 2, 1); } if (strstr(str, "\\P")) /* Do not log the password itself. */ LogPrintf(LogCHAT, "sending: %s\n", str); @@ -615,7 +615,7 @@ DoChat(char *script) } numaborts = 0; - memset(vector, '\0', sizeof(vector)); + memset(vector, '\0', sizeof vector); argc = MakeArgs(script, vector, VECSIZE(vector)); argv = vector; TimeoutSec = 30; diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 5400c3a86c3..53a5d0226e9 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.12 1997/12/23 22:38:01 brian Exp $ + * $Id: command.c,v 1.13 1997/12/24 09:30:27 brian Exp $ * */ #include <sys/param.h> @@ -766,18 +766,18 @@ RunCommand(int argc, char const *const *argv, const char *label) *buf = '\0'; if (label) { - strncpy(buf, label, sizeof(buf) - 3); - buf[sizeof(buf)-3] = '\0'; + strncpy(buf, label, sizeof buf - 3); + buf[sizeof buf - 3] = '\0'; strcat(buf, ": "); } n = strlen(buf); for (f = 0; f < argc; f++) { - if (n < sizeof(buf)-1 && f) + if (n < sizeof buf - 1 && f) buf[n++] = ' '; if (arghidden(argc, argv, f)) - strncpy(buf+n, HIDDEN, sizeof(buf)-n-1); + strncpy(buf+n, HIDDEN, sizeof buf - n - 1); else - strncpy(buf+n, argv[f], sizeof(buf)-n-1); + strncpy(buf+n, argv[f], sizeof buf - n - 1); n += strlen(buf+n); } LogPrintf(LogCOMMAND, "%s\n", buf); @@ -999,7 +999,7 @@ SetServer(struct cmdargs const *arg) if (passwd == NULL) VarHaveLocalAuthKey = 0; else { - strncpy(VarLocalAuthKey, passwd, sizeof(VarLocalAuthKey) - 1); + strncpy(VarLocalAuthKey, passwd, sizeof VarLocalAuthKey - 1); VarLocalAuthKey[sizeof VarLocalAuthKey - 1] = '\0'; VarHaveLocalAuthKey = 1; } @@ -1329,28 +1329,28 @@ SetVariable(struct cmdargs const *arg) switch (param) { case VAR_AUTHKEY: - strncpy(VarAuthKey, argp, sizeof(VarAuthKey) - 1); - VarAuthKey[sizeof(VarAuthKey) - 1] = '\0'; + strncpy(VarAuthKey, argp, sizeof VarAuthKey - 1); + VarAuthKey[sizeof VarAuthKey - 1] = '\0'; break; case VAR_AUTHNAME: - strncpy(VarAuthName, argp, sizeof(VarAuthName) - 1); - VarAuthName[sizeof(VarAuthName) - 1] = '\0'; + strncpy(VarAuthName, argp, sizeof VarAuthName - 1); + VarAuthName[sizeof VarAuthName - 1] = '\0'; break; case VAR_DIAL: - strncpy(VarDialScript, argp, sizeof(VarDialScript) - 1); - VarDialScript[sizeof(VarDialScript) - 1] = '\0'; + strncpy(VarDialScript, argp, sizeof VarDialScript - 1); + VarDialScript[sizeof VarDialScript - 1] = '\0'; break; case VAR_LOGIN: - strncpy(VarLoginScript, argp, sizeof(VarLoginScript) - 1); - VarLoginScript[sizeof(VarLoginScript) - 1] = '\0'; + strncpy(VarLoginScript, argp, sizeof VarLoginScript - 1); + VarLoginScript[sizeof VarLoginScript - 1] = '\0'; break; case VAR_DEVICE: if (modem != -1) LogPrintf(LogWARN, "Cannot change device to \"%s\" when \"%s\" is open\n", argp, VarDevice); else { - strncpy(VarDeviceList, argp, sizeof(VarDeviceList) - 1); - VarDeviceList[sizeof(VarDeviceList) - 1] = '\0'; + strncpy(VarDeviceList, argp, sizeof VarDeviceList - 1); + VarDeviceList[sizeof VarDeviceList - 1] = '\0'; } break; case VAR_ACCMAP: @@ -1358,16 +1358,16 @@ SetVariable(struct cmdargs const *arg) VarAccmap = map; break; case VAR_PHONE: - strncpy(VarPhoneList, argp, sizeof(VarPhoneList) - 1); - VarPhoneList[sizeof(VarPhoneList) - 1] = '\0'; - strncpy(VarPhoneCopy, VarPhoneList, sizeof(VarPhoneCopy) - 1); - VarPhoneCopy[sizeof(VarPhoneCopy) - 1] = '\0'; + strncpy(VarPhoneList, argp, sizeof VarPhoneList - 1); + VarPhoneList[sizeof VarPhoneList - 1] = '\0'; + strncpy(VarPhoneCopy, VarPhoneList, sizeof VarPhoneCopy - 1); + VarPhoneCopy[sizeof VarPhoneCopy - 1] = '\0'; VarNextPhone = VarPhoneCopy; VarAltPhone = NULL; break; case VAR_HANGUP: - strncpy(VarHangupScript, argp, sizeof(VarHangupScript) - 1); - VarHangupScript[sizeof(VarHangupScript) - 1] = '\0'; + strncpy(VarHangupScript, argp, sizeof VarHangupScript - 1); + VarHangupScript[sizeof VarHangupScript - 1] = '\0'; break; #ifdef HAVE_DES case VAR_ENC: diff --git a/usr.sbin/ppp/defs.c b/usr.sbin/ppp/defs.c index c0ce7c6303b..08937e68ab2 100644 --- a/usr.sbin/ppp/defs.c +++ b/usr.sbin/ppp/defs.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: defs.c,v 1.3 1997/12/23 22:38:02 brian Exp $ + * $Id: defs.c,v 1.4 1997/12/24 09:30:28 brian Exp $ */ #include <sys/param.h> @@ -56,7 +56,7 @@ void SetLabel(const char *label) { if (label) - strncpy(dstsystem, label, sizeof(dstsystem) - 1); + strncpy(dstsystem, label, sizeof dstsystem - 1); else *dstsystem = '\0'; } @@ -88,7 +88,7 @@ GetShortHost() { char *p; - if (gethostname(VarShortHost, sizeof(VarShortHost))) { + if (gethostname(VarShortHost, sizeof VarShortHost)) { LogPrintf(LogERROR, "GetShortHost: gethostbyname: %s\n", strerror(errno)); return 0; } diff --git a/usr.sbin/ppp/filter.c b/usr.sbin/ppp/filter.c index 755bdec856a..73fa3177db5 100644 --- a/usr.sbin/ppp/filter.c +++ b/usr.sbin/ppp/filter.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: filter.c,v 1.2 1997/12/15 22:44:51 brian Exp $ + * $Id: filter.c,v 1.3 1997/12/24 09:30:29 brian Exp $ * * TODO: Shoud send ICMP error message when we discard packets. */ @@ -301,7 +301,7 @@ Parse(int argc, char const *const *argv, struct filterent * ofp) argv++; proto = P_NONE; - memset(&filterdata, '\0', sizeof(filterdata)); + memset(&filterdata, '\0', sizeof filterdata); if (!strcmp(*argv, "permit")) { action = A_PERMIT; diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c index 6f6af4089c8..caf4938fc35 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.3 1997/12/15 22:44:52 brian Exp $ + * $Id: fsm.c,v 1.4 1997/12/24 09:30:31 brian Exp $ * * TODO: * o Refer loglevel for log output @@ -345,7 +345,7 @@ FsmRecvConfigReq(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp) int ackaction = 0; plen = plength(bp); - flen = ntohs(lhp->length) - sizeof(*lhp); + flen = ntohs(lhp->length) - sizeof *lhp; if (plen < flen) { LogPrintf(LogERROR, "FsmRecvConfigReq: plen (%d) < flen (%d)\n", plen, flen); @@ -464,7 +464,7 @@ FsmRecvConfigNak(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp) int plen, flen; plen = plength(bp); - flen = ntohs(lhp->length) - sizeof(*lhp); + flen = ntohs(lhp->length) - sizeof *lhp; if (plen < flen) { pfree(bp); return; @@ -574,7 +574,7 @@ FsmRecvConfigRej(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp) int plen, flen; plen = plength(bp); - flen = ntohs(lhp->length) - sizeof(*lhp); + flen = ntohs(lhp->length) - sizeof *lhp; if (plen < flen) { pfree(bp); return; diff --git a/usr.sbin/ppp/hdlc.c b/usr.sbin/ppp/hdlc.c index ea38d9dfbef..16477ffbe25 100644 --- a/usr.sbin/ppp/hdlc.c +++ b/usr.sbin/ppp/hdlc.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: hdlc.c,v 1.3 1997/12/06 12:09:08 brian Exp $ + * $Id: hdlc.c,v 1.4 1997/12/24 09:30:32 brian Exp $ * * TODO: */ @@ -355,7 +355,7 @@ static struct { { 0xc481, 0xc481, "Proprietary Node ID Authentication Protocol" } }; -#define NPROTOCOLS (sizeof(protocols)/sizeof(protocols[0])) +#define NPROTOCOLS (sizeof protocols/sizeof protocols[0]) static const char * Protocol2Nam(u_short proto) @@ -477,7 +477,7 @@ HdlcErrorCheck() struct hdlcstat *hp = &HdlcStat; struct hdlcstat *op = &laststat; - if (memcmp(hp, op, sizeof(laststat))) { + if (memcmp(hp, op, sizeof laststat)) { LogPrintf(LogPHASE, "HDLC errors -> FCS: %u ADDR: %u COMD: %u PROTO: %u\n", hp->badfcs - op->badfcs, hp->badaddr - op->badaddr, hp->badcommand - op->badcommand, hp->unknownproto - op->unknownproto); diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c index 4120503042e..0bda3118a45 100644 --- a/usr.sbin/ppp/ip.c +++ b/usr.sbin/ppp/ip.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ip.c,v 1.1 1997/11/23 20:27:34 brian Exp $ + * $Id: ip.c,v 1.2 1997/12/24 09:30:34 brian Exp $ * * TODO: * o Return ICMP message for filterd packet @@ -411,7 +411,7 @@ IpInput(struct mbuf * bp) IpcpAddInOctets(nb); nb = ntohs(((struct ip *) tun.data)->ip_len); - nb += sizeof(tun)-sizeof(tun.data); + nb += sizeof tun - sizeof tun.data; nw = write(tun_out, &tun, nb); if (nw != nb) if (nw == -1) @@ -424,8 +424,9 @@ IpInput(struct mbuf * bp) while ((fptr = VarPacketAliasGetFragment(tun.data)) != NULL) { VarPacketAliasFragmentIn(tun.data, fptr); nb = ntohs(((struct ip *) fptr)->ip_len); - frag = (struct tun_data *)((char *)fptr-sizeof(tun)+sizeof(tun.data)); - nb += sizeof(tun)-sizeof(tun.data); + frag = (struct tun_data *) + ((char *)fptr - sizeof tun + sizeof tun.data); + nb += sizeof tun - sizeof tun.data; nw = write(tun_out, frag, nb); if (nw != nb) if (nw == -1) @@ -438,13 +439,13 @@ IpInput(struct mbuf * bp) } } else if (iresult == PKT_ALIAS_UNRESOLVED_FRAGMENT) { nb = ntohs(((struct ip *) tun.data)->ip_len); - nb += sizeof(tun)-sizeof(tun.data); + nb += sizeof tun - sizeof tun.data; frag = (struct tun_data *)malloc(nb); if (frag == NULL) LogPrintf(LogALERT, "IpInput: Cannot allocate memory for fragment\n"); else { tun_fill_header(*frag, AF_INET); - memcpy(frag->data, tun.data, nb-sizeof(tun)+sizeof(tun.data)); + memcpy(frag->data, tun.data, nb - sizeof tun + sizeof tun.data); VarPacketAliasSaveFragment(frag->data); } } @@ -456,7 +457,7 @@ IpInput(struct mbuf * bp) return; } IpcpAddInOctets(nb); - nb += sizeof(tun)-sizeof(tun.data); + nb += sizeof tun - sizeof tun.data; nw = write(tun_out, &tun, nb); if (nw != nb) if (nw == -1) diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c index 88e0d6ca00a..3b81eecb4de 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.7 1997/12/24 09:29:10 brian Exp $ + * $Id: ipcp.c,v 1.8 1997/12/24 09:30:35 brian Exp $ * * TODO: * o More RFC1772 backwoard compatibility @@ -110,7 +110,7 @@ static const char *cftypes[] = { "IPADDR", /* 3: IP-Address */ }; -#define NCFTYPES (sizeof(cftypes)/sizeof(char *)) +#define NCFTYPES (sizeof cftypes/sizeof cftypes[0]) static const char *cftypes128[] = { /* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */ @@ -121,7 +121,7 @@ static const char *cftypes128[] = { "SECNBNS", /* 132: Secondary NBNS Server Address */ }; -#define NCFTYPES128 (sizeof(cftypes128)/sizeof(char *)) +#define NCFTYPES128 (sizeof cftypes128/sizeof cftypes128[0]) struct pppThroughput throughput; @@ -172,11 +172,11 @@ IpcpDefAddress() struct hostent *hp; char name[200]; - memset(&DefMyAddress, '\0', sizeof(DefMyAddress)); - memset(&DefHisAddress, '\0', sizeof(DefHisAddress)); + memset(&DefMyAddress, '\0', sizeof DefMyAddress); + memset(&DefHisAddress, '\0', sizeof DefHisAddress); TriggerAddress.s_addr = 0; HaveTriggerAddress = 0; - if (gethostname(name, sizeof(name)) == 0) { + if (gethostname(name, sizeof name) == 0) { hp = gethostbyname(name); if (hp && hp->h_addrtype == AF_INET) { memcpy(&DefMyAddress.ipaddr.s_addr, hp->h_addr, hp->h_length); @@ -190,7 +190,7 @@ IpcpInit() if (iplist_isvalid(&DefHisChoice)) iplist_setrandpos(&DefHisChoice); FsmInit(&IpcpFsm); - memset(&IpcpInfo, '\0', sizeof(struct ipcpstate)); + memset(&IpcpInfo, '\0', sizeof IpcpInfo); if ((mode & MODE_DEDICATED) && !GetLabel()) { IpcpInfo.want_ipaddr.s_addr = IpcpInfo.his_ipaddr.s_addr = 0; } else { @@ -302,7 +302,7 @@ IpcpLayerUp(struct fsm * fp) Prompt(); LogPrintf(LogIPCP, "IpcpLayerUp(%d).\n", fp->state); - snprintf(tbuff, sizeof(tbuff), "myaddr = %s ", + snprintf(tbuff, sizeof tbuff, "myaddr = %s ", inet_ntoa(IpcpInfo.want_ipaddr)); if (IpcpInfo.his_compproto >> 16 == PROTO_VJCOMP) @@ -367,11 +367,11 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode_type) type = *cp; length = cp[1]; if (type < NCFTYPES) - snprintf(tbuff, sizeof(tbuff), " %s[%d] ", cftypes[type], length); + snprintf(tbuff, sizeof tbuff, " %s[%d] ", cftypes[type], length); else if (type > 128 && type < 128 + NCFTYPES128) - snprintf(tbuff, sizeof(tbuff), " %s[%d] ", cftypes128[type-128], length); + snprintf(tbuff, sizeof tbuff, " %s[%d] ", cftypes128[type-128], length); else - snprintf(tbuff, sizeof(tbuff), " <%d>[%d] ", type, length); + snprintf(tbuff, sizeof tbuff, " <%d>[%d] ", type, length); switch (type) { case TY_IPADDR: /* RFC1332 */ @@ -415,7 +415,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode_type) case MODE_NAK: if (AcceptableAddr(&DefMyAddress, ipaddr)) { /* Use address suggested by peer */ - snprintf(tbuff2, sizeof(tbuff2), "%s changing address: %s ", tbuff, + snprintf(tbuff2, sizeof tbuff2, "%s changing address: %s ", tbuff, inet_ntoa(IpcpInfo.want_ipaddr)); LogPrintf(LogIPCP, "%s --> %s\n", tbuff2, inet_ntoa(ipaddr)); IpcpInfo.want_ipaddr = ipaddr; @@ -468,7 +468,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode_type) pcomp->proto = htons(PROTO_VJCOMP); pcomp->slots = MAX_STATES - 1; pcomp->compcid = 0; - memcpy(nakp+2, &pcomp, sizeof(pcomp)); + memcpy(nakp+2, &pcomp, sizeof pcomp); nakp += length; } break; @@ -494,7 +494,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode_type) ipaddr.s_addr = *lp; lp = (u_long *) (cp + 6); dstipaddr.s_addr = *lp; - snprintf(tbuff2, sizeof(tbuff2), "%s %s,", tbuff, inet_ntoa(ipaddr)); + snprintf(tbuff2, sizeof tbuff2, "%s %s,", tbuff, inet_ntoa(ipaddr)); LogPrintf(LogIPCP, "%s %s\n", tbuff2, inet_ntoa(dstipaddr)); switch (mode_type) { @@ -505,7 +505,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode_type) ackp += length; break; case MODE_NAK: - snprintf(tbuff2, sizeof(tbuff2), "%s changing address: %s", tbuff, + snprintf(tbuff2, sizeof tbuff2, "%s changing address: %s", tbuff, inet_ntoa(IpcpInfo.want_ipaddr)); LogPrintf(LogIPCP, "%s --> %s\n", tbuff2, inet_ntoa(ipaddr)); IpcpInfo.want_ipaddr = ipaddr; diff --git a/usr.sbin/ppp/iplist.c b/usr.sbin/ppp/iplist.c index aa555039368..937d74cc185 100644 --- a/usr.sbin/ppp/iplist.c +++ b/usr.sbin/ppp/iplist.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: iplist.c,v 1.3 1997/12/23 22:38:02 brian Exp $ + * $Id: iplist.c,v 1.4 1997/12/24 09:30:37 brian Exp $ */ #include <sys/types.h> @@ -149,8 +149,8 @@ iplist_next(struct iplist *list) int iplist_setsrc(struct iplist *list, const char *src) { - strncpy(list->src, src, sizeof(list->src)-1); - list->src[sizeof(list->src)-1] = '\0'; + strncpy(list->src, src, sizeof list->src - 1); + list->src[sizeof list->src - 1] = '\0'; list->cur.srcptr = list->src; do { if (iplist_nextrange(list)) @@ -211,7 +211,7 @@ iplist_ip2pos(struct iplist *list, struct in_addr ip) int f, result; result = -1; - memcpy(&cur, &list->cur, sizeof(cur)); + memcpy(&cur, &list->cur, sizeof cur); for (iplist_first(list), f = 0; f < list->nItems; f++) if (iplist_next(list).s_addr == ip.s_addr) { @@ -219,6 +219,6 @@ iplist_ip2pos(struct iplist *list, struct in_addr ip) break; } - memcpy(&list->cur, &cur, sizeof(list->cur)); + memcpy(&list->cur, &cur, sizeof list->cur); return result; } diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c index ccdc90cc91f..f51187e3a7e 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.3 1997/12/07 23:55:07 brian Exp $ + * $Id: lcp.c,v 1.4 1997/12/24 09:30:38 brian Exp $ * * TODO: * o Validate magic number received from peer. @@ -117,7 +117,7 @@ static const char *cftypes[] = { "LDBACP", /* 23: Link Discriminator for BACP */ }; -#define NCFTYPES (sizeof(cftypes)/sizeof(char *)) +#define NCFTYPES (sizeof cftypes/sizeof cftypes[0]) struct fsm LcpFsm = { "LCP", /* Name of protocol */ @@ -791,7 +791,7 @@ LcpDecodeConfig(u_char *cp, int plen, int mode_type) break; default: - sz = (sizeof(desc)-2)/2; + sz = (sizeof desc - 2) / 2; if (sz > length - 2) sz = length - 2; pos = 0; @@ -803,8 +803,8 @@ LcpDecodeConfig(u_char *cp, int plen, int mode_type) if (mode_type == MODE_REQ) { reqreject: - if (length > sizeof(RejBuff) - (rejp - RejBuff)) { - length = sizeof(RejBuff) - (rejp - RejBuff); + if (length > sizeof RejBuff - (rejp - RejBuff)) { + length = sizeof RejBuff - (rejp - RejBuff); LogPrintf(LogLCP, "Can't REJ length %d - trunating to %d\n", cp[1], length); } diff --git a/usr.sbin/ppp/log.c b/usr.sbin/ppp/log.c index 582e7a2bef1..b841be98512 100644 --- a/usr.sbin/ppp/log.c +++ b/usr.sbin/ppp/log.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: log.c,v 1.2 1997/12/21 14:27:09 brian Exp $ + * $Id: log.c,v 1.3 1997/12/24 09:30:40 brian Exp $ */ #include <sys/param.h> @@ -237,7 +237,7 @@ LogDumpBuff(int lev, const char *hdr, const u_char * ptr, int n) LogPrintf(lev, "%s\n", hdr); while (n > 0) { b = buf; - for (b = buf; b != buf + sizeof(buf) - 2 && n--; b += 3) + for (b = buf; b != buf + sizeof buf - 2 && n--; b += 3) sprintf(b, " %02x", (int) *ptr++); strcpy(b, "\n"); LogPrintf(lev, buf); diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index a4e842c9970..8d8b0fa96c1 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: main.c,v 1.6 1997/12/22 02:28:33 brian Exp $ + * $Id: main.c,v 1.7 1997/12/24 09:30:41 brian Exp $ * * TODO: * o Add commands for traffic summary, version display, etc. @@ -278,7 +278,7 @@ ex_desc(int ex) "reboot", "errdead", "hangup", "term", "nodial", "nologin" }; - if (ex >= 0 && ex < sizeof(desc) / sizeof(*desc)) + if (ex >= 0 && ex < sizeof desc / sizeof *desc) return desc[ex]; snprintf(num, sizeof num, "%d", ex); return num; @@ -545,7 +545,7 @@ main(int argc, char **argv) TtyCommandMode(1); } - snprintf(pid_filename, sizeof(pid_filename), "%stun%d.pid", + snprintf(pid_filename, sizeof pid_filename, "%stun%d.pid", _PATH_VARRUN, tunno); lockfile = ID0fopen(pid_filename, "w"); if (lockfile != NULL) { @@ -616,11 +616,13 @@ ReadTty(void) LogPrintf(LogDEBUG, "termode = %d, netfd = %d, mode = %d\n", TermMode, netfd, mode); if (!TermMode) { - n = read(netfd, linebuff, sizeof(linebuff) - 1); + n = read(netfd, linebuff, sizeof linebuff - 1); if (n > 0) { aft_cmd = 1; if (linebuff[n-1] == '\n') linebuff[--n] = '\0'; + else + linebuff[n] = '\0'; if (n) DecodeCommand(linebuff, n, IsInteractive(0) ? NULL : "Client"); Prompt(); @@ -1021,7 +1023,7 @@ DoLoop(void) /* something to read from modem */ if (LcpFsm.state <= ST_CLOSED) nointr_usleep(10000); - n = read(modem, rbuff, sizeof(rbuff)); + n = read(modem, rbuff, sizeof rbuff); if ((mode & MODE_DIRECT) && n <= 0) { DownConnection(); } else @@ -1052,12 +1054,12 @@ DoLoop(void) } if (tun_in >= 0 && FD_ISSET(tun_in, &rfds)) { /* something to read * from tun */ - n = read(tun_in, &tun, sizeof(tun)); + n = read(tun_in, &tun, sizeof tun); if (n < 0) { LogPrintf(LogERROR, "read from tun: %s\n", strerror(errno)); continue; } - n -= sizeof(tun)-sizeof(tun.data); + n -= sizeof tun - sizeof tun.data; if (n <= 0) { LogPrintf(LogERROR, "read from tun: Only %d bytes read\n", n); continue; diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index d6cf4b53b00..a763f22316e 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.4 1997/12/23 22:38:03 brian Exp $ + * $Id: modem.c,v 1.5 1997/12/24 09:30:42 brian Exp $ * * TODO: */ @@ -364,7 +364,7 @@ OpenConnection(char *host, char *port) if (sock < 0) { return (sock); } - if (connect(sock, (struct sockaddr *) & dest, sizeof(dest)) < 0) { + if (connect(sock, (struct sockaddr *)&dest, sizeof dest) < 0) { LogPrintf(LogWARN, "OpenConnection: connection failed.\n"); return (-1); } @@ -434,7 +434,7 @@ OpenModem() int oldflag; char *host, *port; char *cp; - char tmpDeviceList[sizeof(VarDeviceList)]; + char tmpDeviceList[sizeof VarDeviceList]; char *tmpDevice; if (modem >= 0) @@ -466,13 +466,13 @@ OpenModem() return modem = 0; } } else { - strncpy(tmpDeviceList, VarDeviceList, sizeof(tmpDeviceList)-1); - tmpDeviceList[sizeof(tmpDeviceList)-1] = '\0'; + strncpy(tmpDeviceList, VarDeviceList, sizeof tmpDeviceList - 1); + tmpDeviceList[sizeof tmpDeviceList - 1] = '\0'; for(tmpDevice=strtok(tmpDeviceList, ","); tmpDevice && (modem < 0); tmpDevice=strtok(NULL,",")) { - strncpy(VarDevice, tmpDevice, sizeof(VarDevice)-1); - VarDevice[sizeof(VarDevice)-1]= '\0'; + strncpy(VarDevice, tmpDevice, sizeof VarDevice - 1); + VarDevice[sizeof VarDevice - 1]= '\0'; VarBaseDevice = strrchr(VarDevice, '/'); VarBaseDevice = VarBaseDevice ? VarBaseDevice + 1 : ""; @@ -700,8 +700,8 @@ HangupModem(int flag) if (modem >= 0) { char ScriptBuffer[SCRIPT_LEN]; - strncpy(ScriptBuffer, VarHangupScript, sizeof(ScriptBuffer)-1); - ScriptBuffer[sizeof(ScriptBuffer) - 1] = '\0'; + strncpy(ScriptBuffer, VarHangupScript, sizeof ScriptBuffer - 1); + ScriptBuffer[sizeof ScriptBuffer - 1] = '\0'; LogPrintf(LogDEBUG, "HangupModem: Script: %s\n", ScriptBuffer); if (flag || !(mode & MODE_DEDICATED)) { DoChat(ScriptBuffer); @@ -728,8 +728,8 @@ CloseLogicalModem(void) ClosePhysicalModem(); if (Utmp) { struct utmp ut; - strncpy(ut.ut_line, VarBaseDevice, sizeof(ut.ut_line)-1); - ut.ut_line[sizeof(ut.ut_line)-1] = '\0'; + strncpy(ut.ut_line, VarBaseDevice, sizeof ut.ut_line - 1); + ut.ut_line[sizeof ut.ut_line - 1] = '\0'; if (logout(ut.ut_line)) logwtmp(ut.ut_line, "", ""); else @@ -847,12 +847,12 @@ DialModem() char ScriptBuffer[SCRIPT_LEN]; int excode; - strncpy(ScriptBuffer, VarDialScript, sizeof(ScriptBuffer) - 1); - ScriptBuffer[sizeof(ScriptBuffer) - 1] = '\0'; + strncpy(ScriptBuffer, VarDialScript, sizeof ScriptBuffer - 1); + ScriptBuffer[sizeof ScriptBuffer - 1] = '\0'; if ((excode = DoChat(ScriptBuffer)) > 0) { if (VarTerm) fprintf(VarTerm, "dial OK!\n"); - strncpy(ScriptBuffer, VarLoginScript, sizeof(ScriptBuffer) - 1); + strncpy(ScriptBuffer, VarLoginScript, sizeof ScriptBuffer - 1); if ((excode = DoChat(ScriptBuffer)) > 0) { VarAltPhone = NULL; if (VarTerm) diff --git a/usr.sbin/ppp/os.c b/usr.sbin/ppp/os.c index 298ec0ab353..ccf8c29d3c8 100644 --- a/usr.sbin/ppp/os.c +++ b/usr.sbin/ppp/os.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: os.c,v 1.3 1997/12/15 22:44:55 brian Exp $ + * $Id: os.c,v 1.4 1997/12/24 09:30:44 brian Exp $ * */ #include <sys/param.h> @@ -90,9 +90,9 @@ SetIpDevice(struct in_addr myaddr, close(s); return (0); } - memset(&ifra.ifra_addr, '\0', sizeof(ifra.ifra_addr)); - memset(&ifra.ifra_broadaddr, '\0', sizeof(ifra.ifra_addr)); - memset(&ifra.ifra_mask, '\0', sizeof(ifra.ifra_addr)); + memset(&ifra.ifra_addr, '\0', sizeof ifra.ifra_addr); + memset(&ifra.ifra_broadaddr, '\0', sizeof ifra.ifra_broadaddr); + memset(&ifra.ifra_mask, '\0', sizeof ifra.ifra_mask); if (ID0ioctl(s, SIOCDIFADDR, &ifra) < 0) { LogPrintf(LogERROR, "SetIpDevice: ioctl(SIOCDIFADDR): %s\n", strerror(errno)); @@ -111,9 +111,9 @@ SetIpDevice(struct in_addr myaddr, * If different address has been set, then delete it first. */ if (oldmine.s_addr || oldhis.s_addr) { - memset(&ifra.ifra_addr, '\0', sizeof(ifra.ifra_addr)); - memset(&ifra.ifra_broadaddr, '\0', sizeof(ifra.ifra_addr)); - memset(&ifra.ifra_mask, '\0', sizeof(ifra.ifra_addr)); + memset(&ifra.ifra_addr, '\0', sizeof ifra.ifra_addr); + memset(&ifra.ifra_broadaddr, '\0', sizeof ifra.ifra_broadaddr); + memset(&ifra.ifra_mask, '\0', sizeof ifra.ifra_mask); if (ID0ioctl(s, SIOCDIFADDR, &ifra) < 0) { LogPrintf(LogERROR, "SetIpDevice: ioctl(SIOCDIFADDR): %s\n", strerror(errno)); @@ -126,13 +126,13 @@ SetIpDevice(struct in_addr myaddr, sock_in = (struct sockaddr_in *) & (ifra.ifra_addr); sock_in->sin_family = AF_INET; sock_in->sin_addr = myaddr; - sock_in->sin_len = sizeof(*sock_in); + sock_in->sin_len = sizeof *sock_in; /* Set destination address */ sock_in = (struct sockaddr_in *) & (ifra.ifra_broadaddr); sock_in->sin_family = AF_INET; sock_in->sin_addr = hisaddr; - sock_in->sin_len = sizeof(*sock_in); + sock_in->sin_len = sizeof *sock_in; addr = ntohl(myaddr.s_addr); if (IN_CLASSA(addr)) @@ -151,7 +151,7 @@ SetIpDevice(struct in_addr myaddr, sock_in = (struct sockaddr_in *) & (ifra.ifra_mask); sock_in->sin_family = AF_INET; sock_in->sin_addr.s_addr = htonl(mask); - sock_in->sin_len = sizeof(*sock_in); + sock_in->sin_len = sizeof *sock_in; if (ID0ioctl(s, SIOCAIFADDR, &ifra) < 0) { if (how != SET_TRY) @@ -299,7 +299,7 @@ OpenTunnel(int *ptun) err = ENOENT; for (unit = 0; unit <= MAX_TUN; unit++) { - snprintf(devname, sizeof(devname), "/dev/tun%d", unit); + snprintf(devname, sizeof devname, "/dev/tun%d", unit); tun_out = ID0open(devname, O_RDWR); if (tun_out >= 0) break; @@ -327,8 +327,8 @@ OpenTunnel(int *ptun) */ strncpy(ifname, devname + 5, IFNAMSIZ - 1); - memset(&ifra, '\0', sizeof(ifra)); - memset(&ifrq, '\0', sizeof(ifrq)); + memset(&ifra, '\0', sizeof ifra); + memset(&ifrq, '\0', sizeof ifrq); strncpy(ifrq.ifr_name, ifname, IFNAMSIZ - 1); strncpy(ifra.ifra_name, ifname, IFNAMSIZ - 1); diff --git a/usr.sbin/ppp/pap.c b/usr.sbin/ppp/pap.c index 51e1e0b1290..101c720f173 100644 --- a/usr.sbin/ppp/pap.c +++ b/usr.sbin/ppp/pap.c @@ -18,7 +18,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: pap.c,v 1.1 1997/11/23 20:27:35 brian Exp $ + * $Id: pap.c,v 1.2 1997/12/24 09:30:45 brian Exp $ * * TODO: */ @@ -171,10 +171,10 @@ PapInput(struct mbuf * bp) VarBaseDevice); else { struct utmp ut; - memset(&ut, 0, sizeof(ut)); + memset(&ut, 0, sizeof ut); time(&ut.ut_time); - strncpy(ut.ut_name, cp+1, sizeof(ut.ut_name)-1); - strncpy(ut.ut_line, VarBaseDevice, sizeof(ut.ut_line)-1); + strncpy(ut.ut_name, cp+1, sizeof ut.ut_name - 1); + strncpy(ut.ut_line, VarBaseDevice, sizeof ut.ut_line - 1); if (logout(ut.ut_line)) logwtmp(ut.ut_line, "", ""); login(&ut); diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c index b329db92dba..853406512f5 100644 --- a/usr.sbin/ppp/route.c +++ b/usr.sbin/ppp/route.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: route.c,v 1.7 1997/12/17 21:18:09 brian Exp $ + * $Id: route.c,v 1.8 1997/12/24 09:30:46 brian Exp $ * */ @@ -81,7 +81,7 @@ OsSetRoute(int cmd, LogPrintf(LogERROR, "OsSetRoute: socket(): %s\n", strerror(errno)); return; } - memset(&rtmes, '\0', sizeof(rtmes)); + memset(&rtmes, '\0', sizeof rtmes); rtmes.m_rtm.rtm_version = RTM_VERSION; rtmes.m_rtm.rtm_type = cmd; rtmes.m_rtm.rtm_addrs = RTA_DST; @@ -89,7 +89,7 @@ OsSetRoute(int cmd, rtmes.m_rtm.rtm_pid = getpid(); rtmes.m_rtm.rtm_flags = RTF_UP | RTF_GATEWAY | RTF_STATIC; - memset(&rtdata, '\0', sizeof(rtdata)); + memset(&rtdata, '\0', sizeof rtdata); rtdata.sin_len = 16; rtdata.sin_family = AF_INET; rtdata.sin_port = 0; @@ -107,14 +107,14 @@ OsSetRoute(int cmd, iname = Index2Nam(IfIndex); ilen = strlen(iname); - dl.sdl_len = sizeof(dl)-sizeof(dl.sdl_data)+ilen; + dl.sdl_len = sizeof dl - sizeof dl.sdl_data + ilen; dl.sdl_family = AF_LINK; dl.sdl_index = IfIndex; dl.sdl_type = 0; dl.sdl_nlen = ilen; dl.sdl_alen = 0; dl.sdl_slen = 0; - strcpy(dl.sdl_data, iname); + strncpy(dl.sdl_data, iname, sizeof dl.sdl_data); memcpy(cp, &dl, dl.sdl_len); cp += dl.sdl_len; @@ -219,7 +219,7 @@ p_sockaddr(struct sockaddr *phost, struct sockaddr *pmask, int width) snprintf(buf, sizeof buf, "%.*s", dl->sdl_nlen, dl->sdl_data); else if (dl->sdl_alen) if (dl->sdl_type == IFT_ETHER) - if (dl->sdl_alen < sizeof(buf)/3) { + if (dl->sdl_alen < sizeof buf / 3) { int f; u_char *MAC; @@ -289,8 +289,8 @@ p_flags(u_long f, int max) char name[33], *flags; register struct bits *p = bits; - if (max > sizeof(name)-1) - max = sizeof(name)-1; + if (max > sizeof name - 1) + max = sizeof name - 1; for (flags = name; p->b_mask && flags - name < max; p++) if (p->b_mask & f) @@ -334,10 +334,10 @@ Index2Nam(int idx) for (ptr = buf; ptr < end; ptr += ifm->ifm_msglen) { ifm = (struct if_msghdr *)ptr; dl = (struct sockaddr_dl *)(ifm + 1); - if (ifm->ifm_index > 0 && ifm->ifm_index <= sizeof(ifs)/sizeof(ifs[0]) + if (ifm->ifm_index > 0 && ifm->ifm_index <= sizeof ifs/sizeof ifs[0] && ifs[ifm->ifm_index-1][0] == '\0') { - if ((len = dl->sdl_nlen) > sizeof(ifs[0])-1) - len = sizeof(ifs[0])-1; + if ((len = dl->sdl_nlen) > sizeof ifs[0] - 1) + len = sizeof ifs[0] - 1; strncpy(ifs[ifm->ifm_index-1], dl->sdl_data, len); ifs[ifm->ifm_index-1][len] = '\0'; if (len && nifs < ifm->ifm_index) diff --git a/usr.sbin/ppp/server.c b/usr.sbin/ppp/server.c index e5df97e09e0..840a860a56a 100644 --- a/usr.sbin/ppp/server.c +++ b/usr.sbin/ppp/server.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: server.c,v 1.4 1997/12/21 14:27:12 brian Exp $ + * $Id: server.c,v 1.5 1997/12/24 09:30:49 brian Exp $ */ #include <sys/param.h> @@ -87,7 +87,7 @@ ServerLocalOpen(const char *name, mode_t mask) setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &s, sizeof s); if (mask != (mode_t)-1) mask = umask(mask); - if (bind(s, (struct sockaddr *) & ifsun, sizeof(ifsun)) < 0) { + if (bind(s, (struct sockaddr *)&ifsun, sizeof ifsun) < 0) { if (mask != (mode_t)-1) umask(mask); LogPrintf(LogERROR, "Local: bind: %s\n", strerror(errno)); @@ -138,7 +138,7 @@ ServerTcpOpen(int port) ifsin.sin_addr.s_addr = INADDR_ANY; ifsin.sin_port = htons(port); setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &s, sizeof s); - if (bind(s, (struct sockaddr *) & ifsin, sizeof(ifsin)) < 0) { + if (bind(s, (struct sockaddr *)&ifsin, sizeof ifsin) < 0) { LogPrintf(LogERROR, "Tcp: bind: %s\n", strerror(errno)); if (errno == EADDRINUSE && VarTerm) fprintf(VarTerm, "Wait for a while, then try again.\n"); diff --git a/usr.sbin/ppp/slcompress.c b/usr.sbin/ppp/slcompress.c index 391ea214cec..29a71658694 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.1 1997/11/23 20:27:36 brian Exp $ + * $Id: slcompress.c,v 1.2 1997/12/24 09:30:51 brian Exp $ * * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989: * - Initial distribution. @@ -59,7 +59,7 @@ sl_compress_init(struct slcompress * comp, int max_state) register u_int i; register struct cstate *tstate = comp->tstate; - memset(comp, '\0', sizeof(*comp)); + memset(comp, '\0', sizeof *comp); for (i = max_state; i > 0; --i) { tstate[i].cs_id = i; tstate[i].cs_next = &tstate[i - 1]; diff --git a/usr.sbin/ppp/systems.c b/usr.sbin/ppp/systems.c index 3382f874a26..c1157e94276 100644 --- a/usr.sbin/ppp/systems.c +++ b/usr.sbin/ppp/systems.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: systems.c,v 1.6 1997/12/21 03:41:27 brian Exp $ + * $Id: systems.c,v 1.7 1997/12/24 09:30:53 brian Exp $ * * TODO: */ @@ -250,7 +250,7 @@ ReadSystem(const char *name, const char *file, int doexec) LogPrintf(LogDEBUG, "ReadSystem: Checking %s (%s).\n", name, filename); linenum = 0; - while (fgets(line, sizeof(line), fp)) { + while (fgets(line, sizeof line, fp)) { linenum++; cp = line; switch (*cp) { @@ -283,7 +283,7 @@ ReadSystem(const char *name, const char *file, int doexec) break; } } else if (strcmp(cp, name) == 0) { - while (fgets(line, sizeof(line), fp)) { + while (fgets(line, sizeof line, fp)) { cp = line; if (issep(*cp)) { n = strspn(cp, " \t"); |