WARNS=4, de-__P()
This commit is contained in:
parent
2cdc2afb8f
commit
845a6a342a
@ -1,6 +1,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PROG= sa
|
||||
WARNS?= 4
|
||||
MAN= sa.8
|
||||
SRCS= main.c pdb.c usrdb.c
|
||||
|
||||
|
@ -60,30 +60,27 @@ struct userinfo {
|
||||
|
||||
/* typedefs */
|
||||
|
||||
typedef int (*cmpf_t) __P((const DBT *, const DBT *));
|
||||
|
||||
/* external functions in sa.c */
|
||||
int main __P((int, char **));
|
||||
typedef int (*cmpf_t)(const DBT *, const DBT *);
|
||||
|
||||
/* external functions in pdb.c */
|
||||
int pacct_init __P((void));
|
||||
void pacct_destroy __P((void));
|
||||
int pacct_add __P((const struct cmdinfo *));
|
||||
int pacct_update __P((void));
|
||||
void pacct_print __P((void));
|
||||
int pacct_init(void);
|
||||
void pacct_destroy(void);
|
||||
int pacct_add(const struct cmdinfo *);
|
||||
int pacct_update(void);
|
||||
void pacct_print(void);
|
||||
|
||||
/* external functions in usrdb.c */
|
||||
int usracct_init __P((void));
|
||||
void usracct_destroy __P((void));
|
||||
int usracct_add __P((const struct cmdinfo *));
|
||||
int usracct_update __P((void));
|
||||
void usracct_print __P((void));
|
||||
int usracct_init(void);
|
||||
void usracct_destroy(void);
|
||||
int usracct_add(const struct cmdinfo *);
|
||||
int usracct_update(void);
|
||||
void usracct_print(void);
|
||||
|
||||
/* variables */
|
||||
|
||||
extern int aflag, bflag, cflag, dflag, Dflag, fflag, iflag, jflag, kflag;
|
||||
extern int Kflag, lflag, mflag, qflag, rflag, sflag, tflag, uflag, vflag;
|
||||
extern int cutoff;
|
||||
extern u_quad_t cutoff;
|
||||
extern cmpf_t sa_cmp;
|
||||
|
||||
/* some #defines to help with db's stupidity */
|
||||
|
@ -56,36 +56,37 @@ static const char rcsid[] =
|
||||
#include "extern.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
static int acct_load __P((char *, int));
|
||||
static u_quad_t decode_comp_t __P((comp_t));
|
||||
static int cmp_comm __P((const char *, const char *));
|
||||
static int cmp_usrsys __P((const DBT *, const DBT *));
|
||||
static int cmp_avgusrsys __P((const DBT *, const DBT *));
|
||||
static int cmp_dkio __P((const DBT *, const DBT *));
|
||||
static int cmp_avgdkio __P((const DBT *, const DBT *));
|
||||
static int cmp_cpumem __P((const DBT *, const DBT *));
|
||||
static int cmp_avgcpumem __P((const DBT *, const DBT *));
|
||||
static int cmp_calls __P((const DBT *, const DBT *));
|
||||
static void usage __P((void));
|
||||
static int acct_load(char *, int);
|
||||
static u_quad_t decode_comp_t(comp_t);
|
||||
static int cmp_comm(const char *, const char *);
|
||||
static int cmp_usrsys(const DBT *, const DBT *);
|
||||
static int cmp_avgusrsys(const DBT *, const DBT *);
|
||||
static int cmp_dkio(const DBT *, const DBT *);
|
||||
static int cmp_avgdkio(const DBT *, const DBT *);
|
||||
static int cmp_cpumem(const DBT *, const DBT *);
|
||||
static int cmp_avgcpumem(const DBT *, const DBT *);
|
||||
static int cmp_calls(const DBT *, const DBT *);
|
||||
static void usage(void);
|
||||
|
||||
int aflag, bflag, cflag, dflag, Dflag, fflag, iflag, jflag, kflag;
|
||||
int Kflag, lflag, mflag, qflag, rflag, sflag, tflag, uflag, vflag;
|
||||
int cutoff = 1;
|
||||
u_quad_t cutoff = 1;
|
||||
|
||||
static char *dfltargv[] = { _PATH_ACCT };
|
||||
static char *dfltargv[] = { NULL };
|
||||
static int dfltargc = (sizeof dfltargv/sizeof(char *));
|
||||
|
||||
/* default to comparing by sum of user + system time */
|
||||
cmpf_t sa_cmp = cmp_usrsys;
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char ch;
|
||||
char pathacct[] = _PATH_ACCT;
|
||||
int error = 0;
|
||||
|
||||
dfltargv[0] = pathacct;
|
||||
|
||||
while ((ch = getopt(argc, argv, "abcdDfijkKlmnqrstuv:")) != -1)
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
@ -239,7 +240,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;
|
||||
}
|
||||
|
||||
@ -266,7 +267,7 @@ main(argc, argv)
|
||||
* close the opened accounting file
|
||||
*/
|
||||
if (close(fd) == -1) {
|
||||
warn("close %s", argv);
|
||||
warn("close %s", *argv);
|
||||
error = 1;
|
||||
}
|
||||
}
|
||||
@ -326,14 +327,14 @@ acct_load(pn, wr)
|
||||
rv = read(fd, &ac, sizeof(struct acct));
|
||||
if (rv == -1)
|
||||
warn("error reading %s", pn);
|
||||
else if (rv > 0 && rv < sizeof(struct acct))
|
||||
else if (rv > 0 && rv < (int)sizeof(struct acct))
|
||||
warnx("short read of accounting data in %s", pn);
|
||||
if (rv != sizeof(struct acct))
|
||||
break;
|
||||
|
||||
/* decode it */
|
||||
ci.ci_calls = 1;
|
||||
for (i = 0; i < sizeof ac.ac_comm && ac.ac_comm[i] != '\0';
|
||||
for (i = 0; i < (int)sizeof ac.ac_comm && ac.ac_comm[i] != '\0';
|
||||
i++) {
|
||||
char c = ac.ac_comm[i];
|
||||
|
||||
|
@ -400,11 +400,14 @@ print_ci(cip, totalcip)
|
||||
}
|
||||
}
|
||||
|
||||
if (tflag)
|
||||
if (tflag) {
|
||||
if (!uflow)
|
||||
printf("%8.2fre/cp ", cip->ci_etime / (double) (cip->ci_utime + cip->ci_stime));
|
||||
printf("%8.2fre/cp ",
|
||||
cip->ci_etime /
|
||||
(double) (cip->ci_utime + cip->ci_stime));
|
||||
else
|
||||
printf("*ignore* ");
|
||||
}
|
||||
|
||||
if (Dflag)
|
||||
printf("%10qutio ", cip->ci_io);
|
||||
|
Loading…
Reference in New Issue
Block a user