From 030f399dac381fc193d31c47fed7b9f17fa2558f Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Sat, 20 Mar 2004 17:46:48 +0000 Subject: [PATCH] Style(9) cleanup. - Remove ``register'' keywords. - No space after ``sizeof''. - Convert K&R-style function declarations to ANSI style. - Remove (void) when ignoring return values. --- usr.sbin/ac/ac.c | 50 ++++++++++++++++++------------------ usr.sbin/dev_mkdb/dev_mkdb.c | 16 ++++++------ usr.sbin/diskpart/diskpart.c | 21 ++++++++------- usr.sbin/inetd/inetd.c | 44 +++++++++++++++---------------- usr.sbin/slstat/slstat.c | 21 +++++++-------- 5 files changed, 74 insertions(+), 78 deletions(-) diff --git a/usr.sbin/ac/ac.c b/usr.sbin/ac/ac.c index 27ba1f7239..ab260112fd 100644 --- a/usr.sbin/ac/ac.c +++ b/usr.sbin/ac/ac.c @@ -13,7 +13,7 @@ * other than his own. * * $FreeBSD: src/usr.sbin/ac/ac.c,v 1.14.2.2 2002/03/12 19:55:04 phantom Exp $ - * $DragonFly: src/usr.sbin/ac/ac.c,v 1.5 2003/11/15 20:33:42 eirikn Exp $ + * $DragonFly: src/usr.sbin/ac/ac.c,v 1.6 2004/03/20 17:46:47 cpressey Exp $ */ #include @@ -69,7 +69,7 @@ static int Flags = 0; static struct user_list *Users = NULL; static struct tty_list *Ttys = NULL; -#define NEW(type) (type *)malloc(sizeof (type)) +#define NEW(type) (type *)malloc(sizeof(type)) #define AC_W 1 /* not _PATH_WTMP */ #define AC_D 2 /* daily totals (ignore -p) */ @@ -116,7 +116,7 @@ struct tty_list * add_tty(char *name) { struct tty_list *tp; - register char *rcp; + char *rcp; Flags |= AC_T; @@ -128,8 +128,8 @@ add_tty(char *name) tp->ret = 0; name++; } - (void)strncpy(tp->name, name, sizeof (tp->name) - 1); - tp->name[sizeof (tp->name) - 1] = '\0'; + strncpy(tp->name, name, sizeof(tp->name) - 1); + tp->name[sizeof(tp->name) - 1] = '\0'; if ((rcp = strchr(tp->name, '*')) != NULL) { /* wild card */ *rcp = '\0'; tp->len = strlen(tp->name); /* match len bytes only */ @@ -155,7 +155,7 @@ do_tty(char *name) if (strncmp(name, tp->name, tp->len) == 0) return tp->ret; } else { - if (strncmp(name, tp->name, sizeof (tp->name)) == 0) + if (strncmp(name, tp->name, sizeof(tp->name)) == 0) return tp->ret; } } @@ -173,7 +173,7 @@ on_console(struct utmp_list *head) for (up = head; up; up = up->next) { if (strncmp(up->usr.ut_line, Console, - sizeof (up->usr.ut_line)) == 0) + sizeof(up->usr.ut_line)) == 0) return 1; } return 0; @@ -204,8 +204,8 @@ update_user(struct user_list *head, char *name, time_t secs) if ((up = NEW(struct user_list)) == NULL) errx(1, "malloc failed"); up->next = head; - (void)strncpy(up->name, name, sizeof (up->name) - 1); - up->name[sizeof (up->name) - 1] = '\0'; /* paranoid! */ + strncpy(up->name, name, sizeof(up->name) - 1); + up->name[sizeof(up->name) - 1] = '\0'; /* paranoid! */ up->secs = secs; Total += secs; return up; @@ -217,7 +217,7 @@ main(int argc, char **argv) FILE *fp; int c; - (void) setlocale(LC_TIME, ""); + setlocale(LC_TIME, ""); fp = NULL; while ((c = getopt(argc, argv, "Dc:dpt:w:")) != -1) { @@ -283,7 +283,7 @@ main(int argc, char **argv) void show(char *name, time_t secs) { - (void)printf("\t%-*s %8.2f\n", UT_NAMESIZE, name, + printf("\t%-*s %8.2f\n", UT_NAMESIZE, name, ((double)secs / 3600)); } @@ -310,7 +310,7 @@ show_today(struct user_list *users, struct utmp_list *logins, time_t secs) if (d_first < 0) d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); - (void)strftime(date, sizeof (date), + strftime(date, sizeof(date), d_first ? "%e %b total" : "%b %e total", localtime(&yesterday)); @@ -328,7 +328,7 @@ show_today(struct user_list *users, struct utmp_list *logins, time_t secs) up->secs = 0; /* for next day */ } if (secs) - (void)printf("%s %11.2f\n", date, ((double)secs / 3600)); + printf("%s %11.2f\n", date, ((double)secs / 3600)); } /* @@ -344,15 +344,15 @@ log_out(struct utmp_list *head, struct utmp *up) for (lp = head, lp2 = NULL; lp != NULL; ) if (*up->ut_line == '~' || strncmp(lp->usr.ut_line, up->ut_line, - sizeof (up->ut_line)) == 0) { + sizeof(up->ut_line)) == 0) { secs = up->ut_time - lp->usr.ut_time; Users = update_user(Users, lp->usr.ut_name, secs); #ifdef DEBUG if (Debug) printf("%-.*s %-.*s: %-.*s logged out (%2d:%02d:%02d)\n", 19, ctime(&up->ut_time), - sizeof (lp->usr.ut_line), lp->usr.ut_line, - sizeof (lp->usr.ut_name), lp->usr.ut_name, + sizeof(lp->usr.ut_line), lp->usr.ut_line, + sizeof(lp->usr.ut_name), lp->usr.ut_name, secs / 3600, (secs % 3600) / 60, secs % 60); #endif /* @@ -408,8 +408,8 @@ log_in(struct utmp_list *head, struct utmp *up) /* * this allows us to pick the right logout */ - (void)strncpy(up->ut_line, Console, sizeof (up->ut_line) - 1); - up->ut_line[sizeof (up->ut_line) - 1] = '\0'; /* paranoid! */ + strncpy(up->ut_line, Console, sizeof(up->ut_line) - 1); + up->ut_line[sizeof(up->ut_line) - 1] = '\0'; /* paranoid! */ } #endif /* @@ -427,14 +427,14 @@ log_in(struct utmp_list *head, struct utmp *up) errx(1, "malloc failed"); lp->next = head; head = lp; - memmove((char *)&lp->usr, (char *)up, sizeof (struct utmp)); + memmove((char *)&lp->usr, (char *)up, sizeof(struct utmp)); #ifdef DEBUG if (Debug) { printf("%-.*s %-.*s: %-.*s logged in", 19, - ctime(&lp->usr.ut_time), sizeof (up->ut_line), - up->ut_line, sizeof (up->ut_name), up->ut_name); + ctime(&lp->usr.ut_time), sizeof(up->ut_line), + up->ut_line, sizeof(up->ut_name), up->ut_name); if (*up->ut_host) - printf(" (%-.*s)", sizeof (up->ut_host), up->ut_host); + printf(" (%-.*s)", sizeof(up->ut_host), up->ut_host); putchar('\n'); } #endif @@ -499,10 +499,10 @@ ac(FILE *fp) break; } } - (void)fclose(fp); + fclose(fp); if (!(Flags & AC_W)) usr.ut_time = time((time_t *)0); - (void)strcpy(usr.ut_line, "~"); + strcpy(usr.ut_line, "~"); if (Flags & AC_D) { ltm = localtime(&usr.ut_time); @@ -535,7 +535,7 @@ ac(FILE *fp) void usage(void) { - (void)fprintf(stderr, + fprintf(stderr, #ifdef CONSOLE_TTY "ac [-dp] [-c console] [-t tty] [-w wtmp] [users ...]\n"); #else diff --git a/usr.sbin/dev_mkdb/dev_mkdb.c b/usr.sbin/dev_mkdb/dev_mkdb.c index 914741566b..8c5b95d199 100644 --- a/usr.sbin/dev_mkdb/dev_mkdb.c +++ b/usr.sbin/dev_mkdb/dev_mkdb.c @@ -33,7 +33,7 @@ * @(#) Copyright (c) 1990, 1993 The Regents of the University of California. All rights reserved. * @(#)dev_mkdb.c 8.1 (Berkeley) 6/6/93 * $FreeBSD: src/usr.sbin/dev_mkdb/dev_mkdb.c,v 1.4.2.1 2001/11/25 18:34:09 iedowse Exp $ - * $DragonFly: src/usr.sbin/dev_mkdb/dev_mkdb.c,v 1.4 2003/11/16 14:10:45 eirikn Exp $ + * $DragonFly: src/usr.sbin/dev_mkdb/dev_mkdb.c,v 1.5 2004/03/20 17:46:47 cpressey Exp $ */ #include @@ -56,8 +56,8 @@ static void usage(void); int main(int argc, char **argv) { - register DIR *dirp; - register struct dirent *dp; + DIR *dirp; + struct dirent *dp; struct stat sb; struct { mode_t type; @@ -92,10 +92,10 @@ main(int argc, char **argv) dirname = _PATH_DEV; if (!fflag) { - (void)snprintf(dbname, sizeof(dbtmp), "%sdev.db", _PATH_VARRUN); - (void)snprintf(dbtmp, sizeof(dbtmp), "%sdev.tmp", _PATH_VARRUN); + snprintf(dbname, sizeof(dbtmp), "%sdev.db", _PATH_VARRUN); + snprintf(dbtmp, sizeof(dbtmp), "%sdev.tmp", _PATH_VARRUN); } else - (void)snprintf(dbtmp, sizeof(dbtmp), "%s.tmp", dbname); + snprintf(dbtmp, sizeof(dbtmp), "%s.tmp", dbname); if (chdir(dirname)) err(1, "%s", dirname); @@ -142,7 +142,7 @@ main(int argc, char **argv) if ((db->put)(db, &key, &data, 0)) err(1, "dbput %s", dbtmp); } - (void)(db->close)(db); + (db->close)(db); if (rename(dbtmp, dbname)) err(1, "rename %s to %s", dbtmp, dbname); exit(0); @@ -151,6 +151,6 @@ main(int argc, char **argv) static void usage(void) { - (void)fprintf(stderr, "usage: dev_mkdb [-f file] [directory]\n"); + fprintf(stderr, "usage: dev_mkdb [-f file] [directory]\n"); exit(1); } diff --git a/usr.sbin/diskpart/diskpart.c b/usr.sbin/diskpart/diskpart.c index 2b9ea2d955..76f1797768 100644 --- a/usr.sbin/diskpart/diskpart.c +++ b/usr.sbin/diskpart/diskpart.c @@ -33,7 +33,7 @@ * @(#) Copyright (c) 1983, 1988, 1993 The Regents of the University of California. All rights reserved. * @(#)diskpart.c 8.3 (Berkeley) 11/30/94 * $FreeBSD: src/usr.sbin/diskpart/diskpart.c,v 1.11.2.2 2002/12/04 16:24:08 roam Exp $ - * $DragonFly: src/usr.sbin/diskpart/Attic/diskpart.c,v 1.4 2003/11/16 14:10:45 eirikn Exp $ + * $DragonFly: src/usr.sbin/diskpart/Attic/diskpart.c,v 1.5 2004/03/20 17:46:47 cpressey Exp $ */ /* @@ -112,7 +112,7 @@ int main(int argc, char **argv) { struct disklabel *dp; - register int curcyl, spc, def, part, layout, j; + int curcyl, spc, def, part, layout, j; int threshhold, numcyls[NPARTITIONS], startcyl[NPARTITIONS]; int totsize = 0; char *lp, *tyname; @@ -382,12 +382,12 @@ promptfordisk(char *name) fprintf(stderr, "%s: unknown disk type, want to supply parameters (y/n)? ", name); - (void) mygets(buf); + mygets(buf); if (*buf != 'y') return ((struct disklabel *)0); for (;;) { fprintf(stderr, "Disk/controller type (%s)? ", dktypenames[1]); - (void) mygets(buf); + mygets(buf); if (buf[0] == 0) { dp->d_type = 1; break; @@ -405,7 +405,7 @@ promptfordisk(char *name) gettype: dp->d_flags = 0; fprintf(stderr, "type (winchester|removable|simulated)? "); - (void) mygets(buf); + mygets(buf); if (strcmp(buf, "removable") == 0) dp->d_flags = D_REMOVABLE; else if (strcmp(buf, "simulated") == 0) @@ -419,7 +419,7 @@ gettype: if (dp->d_type == DTYPE_SMD) fprintf(stderr, "Do %ss support bad144 bad block forwarding (yes)? ", dp->d_typename); - (void) mygets(buf); + mygets(buf); if (*buf != 'n') dp->d_flags |= D_BADSECT; for (fp = fields; fp->f_name != NULL; fp++) { @@ -444,7 +444,7 @@ again: } fprintf(stderr, "sectors/cylinder (%d)? ", dp->d_nsectors * dp->d_ntracks); - (void) mygets(buf); + mygets(buf); if (buf[0] == 0) dp->d_secpercyl = dp->d_nsectors * dp->d_ntracks; else @@ -452,7 +452,7 @@ again: fprintf(stderr, "Drive-type-specific parameters, to terminate:\n"); for (i = 0; i < NDDATA; i++) { fprintf(stderr, "d%d? ", i); - (void) mygets(buf); + mygets(buf); if (buf[0] == 0) break; dp->d_drivedata[i] = atol(buf); @@ -462,7 +462,7 @@ again: gettype(char *t, char **names) { - register char **nm; + char **nm; for (nm = names; *nm; nm++) if (ustrcmp(t, *nm) == 0) @@ -472,8 +472,7 @@ gettype(char *t, char **names) return (-1); } -ustrcmp(s1, s2) - register char *s1, *s2; +ustrcmp(char *s1, char *s2) { #define lower(c) (islower(c) ? (c) : tolower(c)) diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c index 8d06a244b1..2697cee105 100644 --- a/usr.sbin/inetd/inetd.c +++ b/usr.sbin/inetd/inetd.c @@ -33,7 +33,7 @@ * @(#) Copyright (c) 1983, 1991, 1993, 1994 The Regents of the University of California. All rights reserved. * @(#)from: inetd.c 8.4 (Berkeley) 4/13/94 * $FreeBSD: src/usr.sbin/inetd/inetd.c,v 1.80.2.11 2003/04/05 13:39:18 dwmalone Exp $ - * $DragonFly: src/usr.sbin/inetd/inetd.c,v 1.4 2003/11/16 15:17:36 eirikn Exp $ + * $DragonFly: src/usr.sbin/inetd/inetd.c,v 1.5 2004/03/20 17:46:48 cpressey Exp $ */ /* @@ -224,7 +224,7 @@ void setup(struct servtab *); #ifdef IPSEC void ipsecsetup(struct servtab *); #endif -void unregisterrpc(register struct servtab *sep); +void unregisterrpc(struct servtab *sep); static struct conninfo *search_conn(struct servtab *sep, int ctrl); static int room_conn(struct servtab *sep, struct conninfo *conn); static void addchild_conn(struct conninfo *conn, pid_t pid); @@ -502,9 +502,9 @@ main(int argc, char **argv) #define DUMMYSIZE 100 char dummy[DUMMYSIZE]; - (void)memset(dummy, 'x', DUMMYSIZE - 1); + memset(dummy, 'x', DUMMYSIZE - 1); dummy[DUMMYSIZE - 1] = '\0'; - (void)setenv("inetd_dummy", dummy, 1); + setenv("inetd_dummy", dummy, 1); } if (pipe(signalpipe) != 0) { @@ -642,7 +642,7 @@ main(int argc, char **argv) } syslog(LOG_INFO,"%s from %s", sep->se_service, pname); } - (void) sigblock(SIGBLOCK); + sigblock(SIGBLOCK); pid = 0; /* * Fork for all external services, builtins which need to @@ -651,11 +651,11 @@ main(int argc, char **argv) */ if (dofork) { if (sep->se_count++ == 0) - (void)gettimeofday(&sep->se_time, (struct timezone *)NULL); + gettimeofday(&sep->se_time, (struct timezone *)NULL); else if (toomany > 0 && sep->se_count >= toomany) { struct timeval now; - (void)gettimeofday(&now, (struct timezone *)NULL); + gettimeofday(&now, (struct timezone *)NULL); if (now.tv_sec - sep->se_time.tv_sec > CNT_INTVL) { sep->se_time = now; @@ -823,7 +823,7 @@ main(int argc, char **argv) sep->se_service, pwd->pw_gid); _exit(EX_OSERR); } - (void) initgroups(pwd->pw_name, + initgroups(pwd->pw_name, pwd->pw_gid); if (setuid(pwd->pw_uid) < 0) { syslog(LOG_ERR, @@ -1102,7 +1102,7 @@ config(void) syslog(LOG_ERR, "%s/%s unknown RPC service", sep->se_service, sep->se_proto); if (sep->se_fd != -1) - (void) close(sep->se_fd); + close(sep->se_fd); sep->se_fd = -1; continue; } @@ -1111,7 +1111,7 @@ config(void) unregisterrpc(sep); sep->se_rpc_prog = rpc->r_number; if (sep->se_fd != -1) - (void) close(sep->se_fd); + close(sep->se_fd); sep->se_fd = -1; } } @@ -1139,7 +1139,7 @@ config(void) freeconfig(sep); free(sep); } - (void) sigsetmask(omask); + sigsetmask(omask); } void @@ -1164,9 +1164,9 @@ unregisterrpc(struct servtab *sep) for (i = sep->se_rpc_lowvers; i <= sep->se_rpc_highvers; i++) pmap_unset(sep->se_rpc_prog, i); if (sep->se_fd != -1) - (void) close(sep->se_fd); + close(sep->se_fd); sep->se_fd = -1; - (void) sigsetmask(omask); + sigsetmask(omask); } void @@ -1247,7 +1247,7 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on)) ipsecsetup(sep); #endif if (sep->se_family == AF_UNIX) { - (void) unlink(sep->se_ctrladdr_un.sun_path); + unlink(sep->se_ctrladdr_un.sun_path); umask(0777); /* Make socket with conservative permissions */ } if (bind(sep->se_fd, (struct sockaddr *)&sep->se_ctrladdr, @@ -1257,7 +1257,7 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on)) sep->se_service, sep->se_proto); syslog(LOG_ERR, "%s/%s: bind: %m", sep->se_service, sep->se_proto); - (void) close(sep->se_fd); + close(sep->se_fd); sep->se_fd = -1; if (!timingout) { timingout = 1; @@ -1283,7 +1283,7 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on)) syslog(LOG_ERR, "%s/%s: unsupported address family for rpc", sep->se_service, sep->se_proto); - (void) close(sep->se_fd); + close(sep->se_fd); sep->se_fd = -1; return; } @@ -1291,7 +1291,7 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on)) (struct sockaddr*)&sep->se_ctrladdr, &len) < 0){ syslog(LOG_ERR, "%s/%s: getsockname: %m", sep->se_service, sep->se_proto); - (void) close(sep->se_fd); + close(sep->se_fd); sep->se_fd = -1; return; } @@ -1395,7 +1395,7 @@ close_sep(struct servtab *sep) if (sep->se_fd >= 0) { if (FD_ISSET(sep->se_fd, &allsock)) disable(sep); - (void) close(sep->se_fd); + close(sep->se_fd); sep->se_fd = -1; } sep->se_count = 0; @@ -1528,7 +1528,7 @@ void endconfig(void) { if (fconfig) { - (void) fclose(fconfig); + fclose(fconfig); fconfig = NULL; } } @@ -1972,7 +1972,7 @@ again: int c; c = getc(fconfig); - (void) ungetc(c, fconfig); + ungetc(c, fconfig); if (c == ' ' || c == '\t') if ((cp = nextline(fconfig))) goto again; @@ -2029,9 +2029,9 @@ inetd_setproctitle(const char *a, int s) if (getpeername(s, (struct sockaddr *)&ss, &size) == 0) { getnameinfo((struct sockaddr *)&ss, size, pbuf, sizeof(pbuf), NULL, 0, NI_NUMERICHOST|NI_WITHSCOPEID); - (void) sprintf(buf, "%s [%s]", a, pbuf); + sprintf(buf, "%s [%s]", a, pbuf); } else - (void) sprintf(buf, "%s", a); + sprintf(buf, "%s", a); setproctitle("%s", buf); } diff --git a/usr.sbin/slstat/slstat.c b/usr.sbin/slstat/slstat.c index 2b22ba09b0..cfb3a50360 100644 --- a/usr.sbin/slstat/slstat.c +++ b/usr.sbin/slstat/slstat.c @@ -21,7 +21,7 @@ * - Initial distribution. * * $FreeBSD: src/usr.sbin/slstat/slstat.c,v 1.14 1999/08/28 01:20:00 peter Exp $ - * $DragonFly: src/usr.sbin/slstat/slstat.c,v 1.4 2003/11/03 19:31:43 eirikn Exp $ + * $DragonFly: src/usr.sbin/slstat/slstat.c,v 1.5 2004/03/20 17:46:48 cpressey Exp $ */ #include @@ -63,9 +63,7 @@ int unit; int name[6]; int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char **argv) { int c, i; size_t len; @@ -141,7 +139,7 @@ main(argc, argv) #define AMT (sizeof(*sc) - 2 * sizeof(sc->sc_comp.tstate)) static void -usage() +usage(void) { fprintf(stderr, "usage: slstat [-i interval] [-vr] [unit]\n"); exit(1); @@ -156,9 +154,9 @@ u_char signalled; /* set if alarm goes off "early" */ * First line printed at top of screen is always cumulative. */ static void -intpr() +intpr(void) { - register int line = 0; + int line = 0; int oldmask; struct sl_softc *sc, *osc; size_t len; @@ -173,9 +171,9 @@ intpr() (errno != ENOMEM || len != AMT)) err(1, "sysctl linkspecific"); - (void)signal(SIGALRM, catchalarm); + signal(SIGALRM, catchalarm); signalled = 0; - (void)alarm(interval); + alarm(interval); if ((line % 20) == 0) { printf("%8.8s %6.6s %6.6s %6.6s %6.6s", @@ -225,7 +223,7 @@ intpr() } sigsetmask(oldmask); signalled = 0; - (void)alarm(interval); + alarm(interval); bcopy((char *)sc, (char *)osc, AMT); } } @@ -235,8 +233,7 @@ intpr() * Sets a flag to not wait for the alarm. */ static void -catchalarm(sig) - int sig; +catchalarm(int sig) { signalled = 1; } -- 2.41.0