diff options
author | zont <zont@FreeBSD.org> | 2012-09-02 11:03:18 +0000 |
---|---|---|
committer | zont <zont@FreeBSD.org> | 2012-09-02 11:03:18 +0000 |
commit | b328cce0e3c98aeb1847de0d9ff290b2c5632d44 (patch) | |
tree | 1ba7a6f85e2b6fce8ea23a11785ab41a6e30daf1 /usr.bin/truss/main.c | |
parent | ae35ddce9cbe472c2d42f344cbdf6039aed67316 (diff) | |
download | FreeBSD-src-b328cce0e3c98aeb1847de0d9ff290b2c5632d44.zip FreeBSD-src-b328cce0e3c98aeb1847de0d9ff290b2c5632d44.tar.gz |
- Style(9) cleanup.
Approved by: kib (mentor)
Diffstat (limited to 'usr.bin/truss/main.c')
-rw-r--r-- | usr.bin/truss/main.c | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/usr.bin/truss/main.c b/usr.bin/truss/main.c index e04e810..d6a1edc 100644 --- a/usr.bin/truss/main.c +++ b/usr.bin/truss/main.c @@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$"); #include "extern.h" #include "syscall.h" -#define MAXARGS 6 +#define MAXARGS 6 static void usage(void) @@ -113,19 +113,19 @@ static struct ex_types { /* * Set the execution type. This is called after every exec, and when - * a process is first monitored. + * a process is first monitored. */ static struct ex_types * set_etype(struct trussinfo *trussinfo) { struct ex_types *funcs; - char progt[32]; - - size_t len = sizeof(progt); - int mib[4]; + size_t len; int error; + int mib[4]; + char progt[32]; + len = sizeof(progt); mib[0] = CTL_KERN; mib[1] = KERN_PROC; mib[2] = KERN_PROC_SV_NAME; @@ -135,7 +135,7 @@ set_etype(struct trussinfo *trussinfo) err(2, "can not get etype"); for (funcs = ex_types; funcs->type; funcs++) - if (!strcmp(funcs->type, progt)) + if (strcmp(funcs->type, progt) == 0) break; if (funcs->type == NULL) { @@ -163,16 +163,13 @@ strsig(int sig) int main(int ac, char **av) { - int c; - int i; - pid_t childpid; - int status; - char **command; struct ex_types *funcs; - int initial_open; - char *fname; struct trussinfo *trussinfo; + char *fname; char *signame; + char **command; + pid_t childpid; + int c, i, initial_open, status; fname = NULL; initial_open = 1; @@ -192,7 +189,7 @@ main(int ac, char **av) case 'p': /* specified pid */ trussinfo->pid = atoi(optarg); /* make sure i don't trace me */ - if(trussinfo->pid == getpid()) { + if (trussinfo->pid == getpid()) { fprintf(stderr, "attempt to grab self.\n"); exit(2); } @@ -221,7 +218,7 @@ main(int ac, char **av) case 's': /* Specified string size */ trussinfo->strsize = atoi(optarg); break; - case 'S': /* Don't trace signals */ + case 'S': /* Don't trace signals */ trussinfo->flags |= NOSIGS; break; default: @@ -288,7 +285,7 @@ START_TRACE: struct timespec timediff; waitevent(trussinfo); - switch(i = trussinfo->pr_why) { + switch (i = trussinfo->pr_why) { case S_SCE: funcs->enter_syscall(trussinfo, MAXARGS); clock_gettime(CLOCK_REALTIME, @@ -301,9 +298,8 @@ START_TRACE: if (trussinfo->curthread->in_fork && (trussinfo->flags & FOLLOWFORKS)) { trussinfo->curthread->in_fork = 0; - childpid = - funcs->exit_syscall(trussinfo, - trussinfo->pr_data); + childpid = funcs->exit_syscall(trussinfo, + trussinfo->pr_data); /* * Fork a new copy of ourself to trace @@ -359,10 +355,10 @@ START_TRACE: timediff.tv_nsec); } if (trussinfo->flags & RELATIVETIMESTAMPS) { - timespecsubt(&trussinfo->after, - &trussinfo->before, &timediff); - fprintf(trussinfo->outfile, "%ld.%09ld ", - (long)timediff.tv_sec, timediff.tv_nsec); + timespecsubt(&trussinfo->after, + &trussinfo->before, &timediff); + fprintf(trussinfo->outfile, "%ld.%09ld ", + (long)timediff.tv_sec, timediff.tv_nsec); } fprintf(trussinfo->outfile, "process exit, rval = %u\n", trussinfo->pr_data); @@ -372,13 +368,14 @@ START_TRACE: } } while (trussinfo->pr_why != S_EXIT); - if (trussinfo->flags & FOLLOWFORKS) + if (trussinfo->flags & FOLLOWFORKS) { do { childpid = wait(&status); } while (childpid != -1); + } - if (trussinfo->flags & COUNTONLY) - print_summary(trussinfo); + if (trussinfo->flags & COUNTONLY) + print_summary(trussinfo); fflush(trussinfo->outfile); |