From 19a16a1bc9e66b4dac4a3028e6fbe50c0973bc9c Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sat, 17 Mar 2012 11:34:43 +0100 Subject: [PATCH] processes plugin: Some more minor coding style fixes. --- src/processes.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/processes.c b/src/processes.c index e58076a3..3822d42c 100644 --- a/src/processes.c +++ b/src/processes.c @@ -1580,7 +1580,6 @@ static int ps_read (void) kvm_t *kd; char errbuf[1024]; struct kinfo_proc *procs; /* array of processes */ - char **argv; int count; /* returns number of processes */ int i; @@ -1616,37 +1615,33 @@ static int ps_read (void) * filter out threads (duplicate PID entries). */ if ((proc_ptr == NULL) || (proc_ptr->ki_pid != procs[i].ki_pid)) { - char cmdline[ARG_MAX]; + char cmdline[ARG_MAX] = ""; _Bool have_cmdline = 0; - memset (cmdline, 0, sizeof (cmdline)); - proc_ptr = &(procs[i]); - /* not probe system processes and processes without arguments*/ + /* Don't probe system processes and processes without arguments */ if (((procs[i].ki_flag & P_SYSTEM) == 0) - && (procs[i].ki_args != NULL )) + && (procs[i].ki_args != NULL)) { + char **argv; + int argc; + int status; + /* retrieve the arguments */ argv = kvm_getargv (kd, proc_ptr, /* nchr = */ 0); - if ( argv != NULL && *argv) + argc = 0; + if ((argv != NULL) && (argv[0] != NULL)) { - int status; - int argc; - - argc = 0; while (argv[argc] != NULL) argc++; - status = strjoin (cmdline, sizeof (cmdline), - argv, argc, " "); - + status = strjoin (cmdline, sizeof (cmdline), argv, argc, " "); if (status < 0) WARNING ("processes plugin: Command line did not fit into buffer."); else have_cmdline = 1; - } - } + } /* if (process has argument list) */ pse.id = procs[i].ki_pid; pse.age = 0; -- 2.30.2