From a8cd6c3725ae7a6ce514013779779ecc1afa1679 Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Sun, 21 Mar 2004 22:41:24 +0000 Subject: [PATCH] Style(9) cleanup. - Convert K&R-style function declarations to ANSI style. - Remove ``register'' keywords. - Remove casts to (void) when ignoring return values. - Minor indentation fixes. --- usr.sbin/quotaon/quotaon.c | 33 +++++------------ usr.sbin/repquota/repquota.c | 58 +++++++++++------------------ usr.sbin/trpt/trpt.c | 71 ++++++++++++++++-------------------- 3 files changed, 62 insertions(+), 100 deletions(-) diff --git a/usr.sbin/quotaon/quotaon.c b/usr.sbin/quotaon/quotaon.c index 343fe1fef8..4b5e432744 100644 --- a/usr.sbin/quotaon/quotaon.c +++ b/usr.sbin/quotaon/quotaon.c @@ -36,7 +36,7 @@ * @(#) Copyright (c) 1980, 1990, 1993 The Regents of the University of California. All rights reserved. * @(#)quotaon.c 8.1 (Berkeley) 6/6/93 * $FreeBSD: src/usr.sbin/quotaon/quotaon.c,v 1.4.2.1 2001/07/19 05:17:06 kris Exp $ - * $DragonFly: src/usr.sbin/quotaon/quotaon.c,v 1.4 2003/11/03 19:31:41 eirikn Exp $ + * $DragonFly: src/usr.sbin/quotaon/quotaon.c,v 1.5 2004/03/21 22:41:24 cpressey Exp $ */ /* @@ -68,11 +68,9 @@ int readonly(struct fstab *); static void usage(void); int -main(argc, argv) - int argc; - char **argv; +main(int argc, char **argv) { - register struct fstab *fs; + struct fstab *fs; char ch, *qfnp, *whoami; long argnum, done = 0; int i, offmode = 0, errs = 0; @@ -139,9 +137,8 @@ main(argc, argv) } static void -usage() +usage(void) { - fprintf(stderr, "%s\n%s\n%s\n%s\n", "usage: quotaon [-g] [-u] [-v] -a", " quotaon [-g] [-u] [-v] filesystem ...", @@ -151,12 +148,8 @@ usage() } int -quotaonoff(fs, offmode, type, qfpathname) - register struct fstab *fs; - int offmode, type; - char *qfpathname; +quotaonoff(struct fstab *fs, int offmode, int type, char *qfpathname) { - if (strcmp(fs->fs_file, "/") && readonly(fs)) return (1); if (offmode) { @@ -183,11 +176,9 @@ quotaonoff(fs, offmode, type, qfpathname) * Check to see if target appears in list of size cnt. */ int -oneof(target, list, cnt) - register char *target, *list[]; - int cnt; +oneof(char *target, char *list[], int cnt) { - register int i; + int i; for (i = 0; i < cnt; i++) if (strcmp(target, list[i]) == 0) @@ -199,12 +190,9 @@ oneof(target, list, cnt) * Check to see if a particular quota is to be enabled. */ int -hasquota(fs, type, qfnamep) - register struct fstab *fs; - int type; - char **qfnamep; +hasquota(struct fstab *fs, int type, char **qfnamep) { - register char *opt; + char *opt; char *cp; static char initname, usrname[100], grpname[100]; static char buf[BUFSIZ]; @@ -238,8 +226,7 @@ hasquota(fs, type, qfnamep) * Verify file system is mounted and not readonly. */ int -readonly(fs) - register struct fstab *fs; +readonly(struct fstab *fs) { struct statfs fsbuf; diff --git a/usr.sbin/repquota/repquota.c b/usr.sbin/repquota/repquota.c index 55ceb2f665..176c880e4e 100644 --- a/usr.sbin/repquota/repquota.c +++ b/usr.sbin/repquota/repquota.c @@ -36,7 +36,7 @@ * @(#) Copyright (c) 1980, 1990, 1993 The Regents of the University of California. All rights reserved. * @(#)repquota.c 8.1 (Berkeley) 6/6/93 * $FreeBSD: src/usr.sbin/repquota/repquota.c,v 1.9.2.2 2002/03/15 22:18:25 mikeh Exp $ - * $DragonFly: src/usr.sbin/repquota/repquota.c,v 1.4 2003/11/03 19:31:41 eirikn Exp $ + * $DragonFly: src/usr.sbin/repquota/repquota.c,v 1.5 2004/03/21 22:41:24 cpressey Exp $ */ /* @@ -95,13 +95,11 @@ char *timeprt(time_t); static void usage(void); int -main(argc, argv) - int argc; - char **argv; +main(int argc, char **argv) { - register struct fstab *fs; - register struct passwd *pw; - register struct group *gr; + struct fstab *fs; + struct passwd *pw; + struct group *gr; int gflag = 0, uflag = 0, errs = 0; long i, argnum, done = 0; char ch, *qfnp; @@ -136,13 +134,13 @@ main(argc, argv) if (gflag) { setgrent(); while ((gr = getgrent()) != 0) - (void) addid((u_long)gr->gr_gid, GRPQUOTA, gr->gr_name); + addid((u_long)gr->gr_gid, GRPQUOTA, gr->gr_name); endgrent(); } if (uflag) { setpwent(); while ((pw = getpwent()) != 0) - (void) addid((u_long)pw->pw_uid, USRQUOTA, pw->pw_name); + addid((u_long)pw->pw_uid, USRQUOTA, pw->pw_name); endpwent(); } setfsent(); @@ -173,21 +171,18 @@ main(argc, argv) } static void -usage() +usage(void) { fprintf(stderr, "%s\n%s\n", - "usage: repquota [-v] [-g] [-u] -a", - " repquota [-v] [-g] [-u] filesystem ..."); + "usage: repquota [-v] [-g] [-u] -a", + " repquota [-v] [-g] [-u] filesystem ..."); exit(1); } int -repquota(fs, type, qfpathname) - register struct fstab *fs; - int type; - char *qfpathname; +repquota(struct fstab *fs, int type, char *qfpathname) { - register struct fileusage *fup; + struct fileusage *fup; FILE *qf; u_long id; struct dqblk dqbuf; @@ -264,11 +259,9 @@ repquota(fs, type, qfpathname) * Check to see if target appears in list of size cnt. */ int -oneof(target, list, cnt) - register char *target, *list[]; - int cnt; +oneof(char *target, char *list[], int cnt) { - register int i; + int i; for (i = 0; i < cnt; i++) if (strcmp(target, list[i]) == 0) @@ -280,12 +273,9 @@ oneof(target, list, cnt) * Check to see if a particular quota is to be enabled. */ int -hasquota(fs, type, qfnamep) - register struct fstab *fs; - int type; - char **qfnamep; +hasquota(struct fstab *fs, int type, char **qfnamep) { - register char *opt; + char *opt; char *cp; static char initname, usrname[100], grpname[100]; static char buf[BUFSIZ]; @@ -310,7 +300,7 @@ hasquota(fs, type, qfnamep) *qfnamep = cp; return (1); } - (void) sprintf(buf, "%s/%s.%s", fs->fs_file, qfname, qfextension[type]); + sprintf(buf, "%s/%s.%s", fs->fs_file, qfname, qfextension[type]); *qfnamep = buf; return (1); } @@ -321,11 +311,9 @@ hasquota(fs, type, qfnamep) * Lookup an id of a specific type. */ struct fileusage * -lookup(id, type) - u_long id; - int type; +lookup(u_long id, int type) { - register struct fileusage *fup; + struct fileusage *fup; for (fup = fuhead[type][id & (FUHASH-1)]; fup != 0; fup = fup->fu_next) if (fup->fu_id == id) @@ -337,10 +325,7 @@ lookup(id, type) * Add a new file usage id if it does not already exist. */ struct fileusage * -addid(id, type, name) - u_long id; - int type; - char *name; +addid(u_long id, int type, char *name) { struct fileusage *fup, **fhp; int len; @@ -371,8 +356,7 @@ addid(id, type, name) * Calculate the grace period and return a printable string for it. */ char * -timeprt(seconds) - time_t seconds; +timeprt(time_t seconds) { time_t hours, minutes; static char buf[20]; diff --git a/usr.sbin/trpt/trpt.c b/usr.sbin/trpt/trpt.c index fae2484eac..f89cd47126 100644 --- a/usr.sbin/trpt/trpt.c +++ b/usr.sbin/trpt/trpt.c @@ -33,7 +33,7 @@ * @(#) Copyright (c) 1983, 1988, 1993 The Regents of the University of California. All rights reserved. * @(#)trpt.c 8.1 (Berkeley) 6/6/93 * $FreeBSD: src/usr.sbin/trpt/trpt.c,v 1.12 2000/01/29 11:49:07 shin Exp $ - * $DragonFly: src/usr.sbin/trpt/trpt.c,v 1.3 2003/11/03 19:31:44 eirikn Exp $ + * $DragonFly: src/usr.sbin/trpt/trpt.c,v 1.4 2004/03/21 22:41:24 cpressey Exp $ */ #include @@ -95,9 +95,7 @@ void tcp_trace(short, short, struct tcpcb *, struct tcpcb *, static void usage(void); int -main(argc, argv) - int argc; - char **argv; +main(int argc, char **argv) { int ch, i, jflag, npcbs; char *system, *core; @@ -118,7 +116,7 @@ main(argc, argv) case 'p': if (npcbs >= TCP_NDEBUG) errx(1, "too many pcb's specified"); - (void)sscanf(optarg, "%x", (int *)&tcp_pcbs[npcbs++]); + sscanf(optarg, "%x", (int *)&tcp_pcbs[npcbs++]); break; case 's': ++sflag; @@ -157,11 +155,11 @@ main(argc, argv) err(2, "%s", core); if (kflag) errx(1, "can't do core files yet"); - (void)klseek(memf, (off_t)nl[N_TCP_DEBX].n_value, L_SET); + klseek(memf, (off_t)nl[N_TCP_DEBX].n_value, L_SET); if (read(memf, (char *)&tcp_debx, sizeof(tcp_debx)) != sizeof(tcp_debx)) err(3, "tcp_debx"); - (void)klseek(memf, (off_t)nl[N_TCP_DEBUG].n_value, L_SET); + klseek(memf, (off_t)nl[N_TCP_DEBUG].n_value, L_SET); if (read(memf, (char *)tcp_debug, sizeof(tcp_debug)) != sizeof(tcp_debug)) err(3, "tcp_debug"); @@ -173,8 +171,8 @@ main(argc, argv) */ if (!npcbs) { for (i = 0; i < TCP_NDEBUG; i++) { - register struct tcp_debug *td = &tcp_debug[i]; - register int j; + struct tcp_debug *td = &tcp_debug[i]; + int j; if (td->td_tcb == 0) continue; @@ -205,21 +203,21 @@ main(argc, argv) } static void -usage() +usage(void) { - (void)fprintf(stderr, - "usage: trpt [-afjst] [-p hex-address] [system [core]]\n"); + fprintf(stderr, + "usage: trpt [-afjst] [-p hex-address] [system [core]]\n"); exit(1); } void -dotrace(tcpcb) - register caddr_t tcpcb; +dotrace(caddr_t tcpcb) { - register struct tcp_debug *td; - register int i; - int prev_debx = tcp_debx, family; + struct tcp_debug *td; + int i; + int prev_debx, family; + prev_debx = tcp_debx; again: if (--tcp_debx < 0) tcp_debx = TCP_NDEBUG - 1; for (i = prev_debx % TCP_NDEBUG; i < TCP_NDEBUG; i++) { @@ -284,12 +282,12 @@ done: if (follow) { prev_debx = 0; do { sleep(1); - (void)klseek(memf, (off_t)nl[N_TCP_DEBX].n_value, L_SET); + klseek(memf, (off_t)nl[N_TCP_DEBX].n_value, L_SET); if (read(memf, (char *)&tcp_debx, sizeof(tcp_debx)) != sizeof(tcp_debx)) err(3, "tcp_debx"); } while (tcp_debx == prev_debx); - (void)klseek(memf, (off_t)nl[N_TCP_DEBUG].n_value, L_SET); + klseek(memf, (off_t)nl[N_TCP_DEBUG].n_value, L_SET); if (read(memf, (char *)tcp_debug, sizeof(tcp_debug)) != sizeof(tcp_debug)) err(3, "tcp_debug"); @@ -302,13 +300,8 @@ done: if (follow) { */ /*ARGSUSED*/ void -tcp_trace(act, ostate, atp, tp, family, ip, th, req) - short act, ostate; - struct tcpcb *atp, *tp; - int family; - void *ip; - struct tcphdr *th; - int req; +tcp_trace(short act, short ostate, struct tcpcb *atp, struct tcpcb *tp, + int family, void *ip, struct tcphdr *th, int req) { tcp_seq seq, ack; int flags, len, win, timer; @@ -392,12 +385,13 @@ tcp_trace(act, ostate, atp, tp, family, ip, th, req) printf("(win=%x)", win); flags = th->th_flags; if (flags) { - register char *cp = "<"; -#define pf(flag, string) { \ - if (th->th_flags&flag) { \ - (void)printf("%s%s", cp, string); \ - cp = ","; \ - } \ + char *cp = "<"; + +#define pf(flag, string) { \ + if (th->th_flags & flag) { \ + printf("%s%s", cp, string); \ + cp = ","; \ + } \ } pf(TH_SYN, "SYN"); pf(TH_ACK, "ACK"); @@ -433,8 +427,8 @@ tcp_trace(act, ostate, atp, tp, family, ip, th, req) * kernel now uses callouts, not integer time values. */ if (tflag) { - register char *cp = "\t"; - register int i; + char *cp = "\t"; + int i; for (i = 0; i < TCPT_NTIMERS; i++) { if (tp->t_timer[i] == 0) @@ -451,16 +445,13 @@ tcp_trace(act, ostate, atp, tp, family, ip, th, req) } int -numeric(c1, c2) - caddr_t *c1, *c2; +numeric(caddr_t *c1, caddr_t *c2) { return(*c1 - *c2); } void -klseek(fd, base, off) - int fd, off; - off_t base; +klseek(int fd, off_t base, int off) { - (void)lseek(fd, base, off); + lseek(fd, base, off); } -- 2.41.0