Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/truss/main.c
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | main(int ac, char **av) | ||||
if (trussinfo == NULL) | if (trussinfo == NULL) | ||||
errx(1, "calloc() failed"); | errx(1, "calloc() failed"); | ||||
pid = 0; | pid = 0; | ||||
trussinfo->outfile = stderr; | trussinfo->outfile = stderr; | ||||
trussinfo->strsize = 32; | trussinfo->strsize = 32; | ||||
trussinfo->curthread = NULL; | trussinfo->curthread = NULL; | ||||
LIST_INIT(&trussinfo->proclist); | LIST_INIT(&trussinfo->proclist); | ||||
init_syscalls(); | |||||
while ((c = getopt(ac, av, "p:o:facedDs:SH")) != -1) { | while ((c = getopt(ac, av, "p:o:facedDs:SH")) != -1) { | ||||
switch (c) { | switch (c) { | ||||
case 'p': /* specified pid */ | case 'p': /* specified pid */ | ||||
pid = atoi(optarg); | pid = atoi(optarg); | ||||
/* make sure i don't trace me */ | /* make sure i don't trace me */ | ||||
if (pid == getpid()) { | if (pid == getpid()) { | ||||
errx(2, "attempt to grab self."); | errx(2, "attempt to grab self."); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | main(int ac, char **av) | ||||
clock_gettime(CLOCK_REALTIME, &trussinfo->start_time); | clock_gettime(CLOCK_REALTIME, &trussinfo->start_time); | ||||
eventloop(trussinfo); | eventloop(trussinfo); | ||||
if (trussinfo->flags & COUNTONLY) | if (trussinfo->flags & COUNTONLY) | ||||
print_summary(trussinfo); | print_summary(trussinfo); | ||||
fflush(trussinfo->outfile); | fflush(trussinfo->outfile); | ||||
jrtc27: We're not freeing on error paths, and we're about to exit here. I don't think we need to bother… | |||||
Done Inline ActionsSure, happy to drop this. I'm not sure if any allocations have happened though if we hit the error return above. arichardson: Sure, happy to drop this. I'm not sure if any allocations have happened though if we hit the… | |||||
return (0); | return (0); | ||||
} | } |
We're not freeing on error paths, and we're about to exit here. I don't think we need to bother with this.