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