pmc: silence scan-build warnings

This commit is contained in:
Matt Macy 2018-05-29 21:02:08 +00:00
parent 4f9b4ac4c2
commit 5244f3c6ae
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=334353

View File

@ -306,21 +306,21 @@ static struct option longopts[] = {
static int static int
pmc_stat_internal(int argc, char **argv, int system_mode) pmc_stat_internal(int argc, char **argv, int system_mode)
{ {
const char *event; char *event, *r;
struct sigaction sa; struct sigaction sa;
struct kevent kev; struct kevent kev;
struct rusage ru; struct rusage ru;
struct winsize ws; struct winsize ws;
struct pmcstat_ev *ev; struct pmcstat_ev *ev;
int c, option, runstate, do_print, do_read; int c, option, runstate;
int waitstatus, ru_valid; int waitstatus, ru_valid;
ru_valid = do_print = do_read = 0; ru_valid = 0;
event = NULL; r = event = NULL;
while ((option = getopt_long(argc, argv, "j:", longopts, NULL)) != -1) { while ((option = getopt_long(argc, argv, "j:", longopts, NULL)) != -1) {
switch (option) { switch (option) {
case 'j': case 'j':
event = strdup(optarg); r = event = strdup(optarg);
break; break;
case '?': case '?':
default: default:
@ -333,7 +333,8 @@ pmc_stat_internal(int argc, char **argv, int system_mode)
usage(); usage();
pmc_args.pa_flags |= FLAG_HAS_COMMANDLINE; pmc_args.pa_flags |= FLAG_HAS_COMMANDLINE;
pmc_stat_setup_stat(system_mode, event); pmc_stat_setup_stat(system_mode, event);
free(r);
bzero(&ru, sizeof(ru));
EV_SET(&kev, SIGINT, EVFILT_SIGNAL, EV_ADD, 0, 0, NULL); EV_SET(&kev, SIGINT, EVFILT_SIGNAL, EV_ADD, 0, 0, NULL);
if (kevent(pmc_kq, &kev, 1, NULL, 0, NULL) < 0) if (kevent(pmc_kq, &kev, 1, NULL, 0, NULL) < 0)
err(EX_OSERR, "ERROR: Cannot register kevent for SIGINT"); err(EX_OSERR, "ERROR: Cannot register kevent for SIGINT");
@ -394,7 +395,6 @@ pmc_stat_internal(int argc, char **argv, int system_mode)
* are killed by a SIGINT or we reached the time duration. * are killed by a SIGINT or we reached the time duration.
*/ */
runstate = PMCSTAT_RUNNING; runstate = PMCSTAT_RUNNING;
do_print = do_read = 0;
do { do {
if ((c = kevent(pmc_kq, NULL, 0, &kev, 1, NULL)) <= 0) { if ((c = kevent(pmc_kq, NULL, 0, &kev, 1, NULL)) <= 0) {
if (errno != EINTR) if (errno != EINTR)
@ -411,11 +411,9 @@ pmc_stat_internal(int argc, char **argv, int system_mode)
getrusage(RUSAGE_CHILDREN, &ru); getrusage(RUSAGE_CHILDREN, &ru);
ru_valid = 1; ru_valid = 1;
} }
do_print = 1;
break; break;
case EVFILT_READ: /* log file data is present */ case EVFILT_READ: /* log file data is present */
do_read = 0;
break; break;
case EVFILT_SIGNAL: case EVFILT_SIGNAL:
@ -439,7 +437,6 @@ pmc_stat_internal(int argc, char **argv, int system_mode)
ru_valid = 1; ru_valid = 1;
} }
runstate = pmcstat_close_log(&pmc_args); runstate = pmcstat_close_log(&pmc_args);
do_print = 1; /* print PMCs at exit */
} else if (kev.ident == SIGINT) { } else if (kev.ident == SIGINT) {
/* Kill the child process if we started it */ /* Kill the child process if we started it */
if (pmc_args.pa_flags & FLAG_HAS_COMMANDLINE) if (pmc_args.pa_flags & FLAG_HAS_COMMANDLINE)