diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-05-30 18:43:41 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-05-30 18:43:41 +0000 |
commit | 29338aa14b1501aa61aace6945c74a2a8809cc62 (patch) | |
tree | afaae71bbb1b2fdd9f2f1073ac59b92a46d82182 /usr.sbin/sa | |
parent | 4c634946379eb2edf9650f9efbcf2a6c3e71780f (diff) |
various repairs; jason@ackley.net
Diffstat (limited to 'usr.sbin/sa')
-rw-r--r-- | usr.sbin/sa/main.c | 46 | ||||
-rw-r--r-- | usr.sbin/sa/pdb.c | 21 | ||||
-rw-r--r-- | usr.sbin/sa/usrdb.c | 12 |
3 files changed, 33 insertions, 46 deletions
diff --git a/usr.sbin/sa/main.c b/usr.sbin/sa/main.c index 2d9a0bd887d..a97ec921ac8 100644 --- a/usr.sbin/sa/main.c +++ b/usr.sbin/sa/main.c @@ -1,3 +1,4 @@ +/* $OpenBSD: main.c,v 1.8 2002/05/30 18:43:40 deraadt Exp $ */ /* * Copyright (c) 1994 Christopher G. Demetriou * All rights reserved. @@ -33,7 +34,7 @@ static char copright[] = "@(#) Copyright (c) 1994 Christopher G. Demetriou\n\ All rights reserved.\n"; -static char rcsid[] = "$Id: main.c,v 1.7 2002/02/16 21:28:09 millert Exp $"; +static char rcsid[] = "$Id: main.c,v 1.8 2002/05/30 18:43:40 deraadt Exp $"; #endif /* @@ -75,12 +76,11 @@ static int dfltargc = (sizeof(dfltargv)/sizeof(char *)); cmpf_t sa_cmp = cmp_usrsys; int -main(argc, argv) - int argc; - char **argv; +main(int argc, char **argv) { int ch; int error = 0; + extern char *__progname; while ((ch = getopt(argc, argv, "abcdDfijkKlmnqrstuv:")) != -1) switch (ch) { @@ -169,7 +169,8 @@ main(argc, argv) case '?': default: (void)fprintf(stderr, - "usage: sa [-abcdDfijkKlmnqrstu] [-v cutoff] [file ...]\n"); + "usage: %s [-abcdDfijkKlmnqrstu] [-v cutoff]" + " [file ...]\n", __progname); exit(1); } @@ -237,7 +238,7 @@ main(argc, argv) * but we want every accounting record intact. */ if (ftruncate(fd, 0) == -1) { - warn("couldn't truncate %s", argv); + warn("couldn't truncate %s", *argv); error = 1; } @@ -264,7 +265,7 @@ main(argc, argv) * close the opened accounting file */ if (close(fd) == -1) { - warn("close %s", argv); + warn("close %s", *argv); error = 1; } } @@ -289,9 +290,7 @@ main(argc, argv) } static int -acct_load(pn, wr) - char *pn; - int wr; +acct_load(char *pn, int wr) { struct acct ac; struct cmdinfo ci; @@ -361,8 +360,7 @@ acct_load(pn, wr) } static u_quad_t -decode_comp_t(comp) - comp_t comp; +decode_comp_t(comp_t comp) { u_quad_t rv; @@ -382,8 +380,7 @@ decode_comp_t(comp) /* sort commands, doing the right thing in terms of reversals */ static int -cmp_comm(s1, s2) - const char *s1, *s2; +cmp_comm(const char *s1, const char *s2) { int rv; @@ -395,8 +392,7 @@ cmp_comm(s1, s2) /* sort by total user and system time */ static int -cmp_usrsys(d1, d2) - const DBT *d1, *d2; +cmp_usrsys(const DBT *d1, const DBT *d2) { struct cmdinfo c1, c2; u_quad_t t1, t2; @@ -417,8 +413,7 @@ cmp_usrsys(d1, d2) /* sort by average user and system time */ static int -cmp_avgusrsys(d1, d2) - const DBT *d1, *d2; +cmp_avgusrsys(const DBT *d1, const DBT *d2) { struct cmdinfo c1, c2; double t1, t2; @@ -442,8 +437,7 @@ cmp_avgusrsys(d1, d2) /* sort by total number of disk I/O operations */ static int -cmp_dkio(d1, d2) - const DBT *d1, *d2; +cmp_dkio(const DBT *d1, const DBT *d2) { struct cmdinfo c1, c2; @@ -460,8 +454,7 @@ cmp_dkio(d1, d2) /* sort by average number of disk I/O operations */ static int -cmp_avgdkio(d1, d2) - const DBT *d1, *d2; +cmp_avgdkio(const DBT *d1, const DBT *d2) { struct cmdinfo c1, c2; double n1, n2; @@ -482,8 +475,7 @@ cmp_avgdkio(d1, d2) /* sort by the cpu-storage integral */ static int -cmp_cpumem(d1, d2) - const DBT *d1, *d2; +cmp_cpumem(const DBT *d1, const DBT *d2) { struct cmdinfo c1, c2; @@ -500,8 +492,7 @@ cmp_cpumem(d1, d2) /* sort by the cpu-time average memory usage */ static int -cmp_avgcpumem(d1, d2) - const DBT *d1, *d2; +cmp_avgcpumem(const DBT *d1, const DBT *d2) { struct cmdinfo c1, c2; u_quad_t t1, t2; @@ -526,8 +517,7 @@ cmp_avgcpumem(d1, d2) /* sort by the number of invocations */ static int -cmp_calls(d1, d2) - const DBT *d1, *d2; +cmp_calls(const DBT *d1, const DBT *d2) { struct cmdinfo c1, c2; diff --git a/usr.sbin/sa/pdb.c b/usr.sbin/sa/pdb.c index 7989bf12d5f..12cf487e816 100644 --- a/usr.sbin/sa/pdb.c +++ b/usr.sbin/sa/pdb.c @@ -1,3 +1,4 @@ +/* $OpenBSD: pdb.c,v 1.5 2002/05/30 18:43:40 deraadt Exp $ */ /* * Copyright (c) 1994 Christopher G. Demetriou * All rights reserved. @@ -29,7 +30,7 @@ */ #ifndef LINT -static char rcsid[] = "$Id: pdb.c,v 1.4 2002/05/22 09:09:32 deraadt Exp $"; +static char rcsid[] = "$Id: pdb.c,v 1.5 2002/05/30 18:43:40 deraadt Exp $"; #endif #include <sys/types.h> @@ -113,8 +114,7 @@ pacct_destroy() } int -pacct_add(ci) - const struct cmdinfo *ci; +pacct_add(const struct cmdinfo *ci) { DBT key, data; struct cmdinfo newci; @@ -300,8 +300,7 @@ next: rv = DB_SEQ(pacct_db, &key, &data, R_NEXT); } static int -check_junk(cip) - struct cmdinfo *cip; +check_junk(struct cmdinfo *cip) { char *cp; size_t len; @@ -313,9 +312,7 @@ check_junk(cip) } static void -add_ci(fromcip, tocip) - const struct cmdinfo *fromcip; - struct cmdinfo *tocip; +add_ci(const struct cmdinfo *fromcip, struct cmdinfo *tocip) { tocip->ci_calls += fromcip->ci_calls; tocip->ci_etime += fromcip->ci_etime; @@ -326,8 +323,7 @@ add_ci(fromcip, tocip) } static void -print_ci(cip, totalcip) - const struct cmdinfo *cip, *totalcip; +print_ci(const struct cmdinfo *cip, const struct cmdinfo *totalcip) { double t, c; int uflow; @@ -397,11 +393,12 @@ print_ci(cip, totalcip) } } - if (tflag) + if (tflag) { if (!uflow) printf("%8.2fre/cp ", cip->ci_etime / (double) (cip->ci_utime + cip->ci_stime)); else - printf("%8 ", "*ignore*"); + printf("%8s ", "*ignore*"); + } if (Dflag) printf("%10qutio ", cip->ci_io); diff --git a/usr.sbin/sa/usrdb.c b/usr.sbin/sa/usrdb.c index a2e5757b02b..306efd65ff4 100644 --- a/usr.sbin/sa/usrdb.c +++ b/usr.sbin/sa/usrdb.c @@ -1,3 +1,4 @@ +/* $OpenBSD: usrdb.c,v 1.5 2002/05/30 18:43:40 deraadt Exp $ */ /* * Copyright (c) 1994 Christopher G. Demetriou * All rights reserved. @@ -29,7 +30,7 @@ */ #ifndef LINT -static char rcsid[] = "$Id: usrdb.c,v 1.4 2002/02/16 21:28:09 millert Exp $"; +static char rcsid[] = "$Id: usrdb.c,v 1.5 2002/05/30 18:43:40 deraadt Exp $"; #endif #include <sys/types.h> @@ -37,6 +38,8 @@ static char rcsid[] = "$Id: usrdb.c,v 1.4 2002/02/16 21:28:09 millert Exp $"; #include <err.h> #include <errno.h> #include <fcntl.h> +#include <pwd.h> +#include <stdio.h> #include <string.h> #include "extern.h" #include "pathnames.h" @@ -116,8 +119,7 @@ usracct_destroy() } int -usracct_add(ci) - const struct cmdinfo *ci; +usracct_add(const struct cmdinfo *ci) { DBT key, data; struct userinfo newui; @@ -211,7 +213,6 @@ usracct_update() warn("syncing process accounting summary"); error = -1; } -out: if (DB_CLOSE(saved_usracct_db) < 0) { warn("closing process accounting summary"); error = -1; @@ -265,8 +266,7 @@ usracct_print() } static int -uid_compare(k1, k2) - const DBT *k1, *k2; +uid_compare(const DBT *k1, const DBT *k2) { u_long d1, d2; |