diff --git a/src/main.c b/src/main.c index 0ddcdae..914ea3a 100644 --- a/src/main.c +++ b/src/main.c @@ -26,7 +26,7 @@ static XtmSettings *settings; static GtkWidget *window; static GtkStatusIcon *status_icon; static XtmTaskManager *task_manager; -static gboolean timeout = 0; +static gboolean timeout = FALSE; static void status_icon_activated (void) diff --git a/src/task-manager-bsd.c b/src/task-manager-bsd.c index 79d1b35..fcdeec5 100644 --- a/src/task-manager-bsd.c +++ b/src/task-manager-bsd.c @@ -102,6 +102,7 @@ gboolean get_task_list (GArray *task_list) #else struct kinfo_proc2 p = kp[i]; #endif + bzero(&t, sizeof(t)); t.pid = p.p_pid; t.ppid = p.p_ppid; t.uid = p.p_uid; @@ -116,6 +117,7 @@ gboolean get_task_list (GArray *task_list) size = 128; if ((args = malloc(size)) == NULL) errx(1,"failed to allocate memory for argv structures at %zu", size); + bzero(args, size); for (;; size *= 2) { if ((args = realloc(args, size)) == NULL) errx(1,"failed to allocate memory (size=%zu) for argv structures of pid %d", size, t.pid); diff --git a/src/task-manager-freebsd.c b/src/task-manager-freebsd.c index 4fbe8d1..3fc52fe 100644 --- a/src/task-manager-freebsd.c +++ b/src/task-manager-freebsd.c @@ -122,6 +122,7 @@ get_task_details (kvm_t *kd, struct kinfo_proc *kp, Task *task) char **argv; int i; + bzero(task, sizeof(Task)); task->pid = kp->ki_pid; task->ppid = kp->ki_ppid; task->cpu_user = 100 * ((double)kp->ki_pctcpu / FSCALE); @@ -213,7 +214,7 @@ get_task_list (GArray *task_list) { kvm_t *kd; struct kinfo_proc *kp; - int cnt, i; + int cnt = 0, i; Task task; if ((kd = kvm_openfiles (_PATH_DEVNULL, _PATH_DEVNULL, NULL, O_RDONLY, NULL)) == NULL) diff --git a/src/task-manager-linux.c b/src/task-manager-linux.c index 488dbdf..3828e10 100644 --- a/src/task-manager-linux.c +++ b/src/task-manager-linux.c @@ -199,6 +199,8 @@ get_task_details (guint pid, Task *task) return FALSE; fclose (file); + bzero(task, sizeof(Task)); + /* Scanning the short process name is unreliable with scanf when it contains * spaces, retrieve it manually and fill the buffer */ { @@ -313,7 +315,7 @@ get_task_list (GArray *task_list) GDir *dir; const gchar *name; guint pid; - Task task = { 0 }; + Task task; if ((dir = g_dir_open ("/proc", 0, NULL)) == NULL) return FALSE; diff --git a/src/task-manager-skel.c b/src/task-manager-skel.c index 06229e8..4f085da 100644 --- a/src/task-manager-skel.c +++ b/src/task-manager-skel.c @@ -50,6 +50,7 @@ get_cpu_usage (gushort *cpu_count, gfloat *cpu_user, gfloat *cpu_system) static gboolean get_task_details (guint pid, Task *task) { + bzero(task, sizeof(Task)); g_snprintf (task->name, sizeof(task->name), "foo"); g_snprintf (task->cmdline, sizeof(task->cmdline), "foo -bar"); g_snprintf (task->uid_name, sizeof(task->uid_name), "baz"); @@ -61,7 +62,7 @@ gboolean get_task_list (GArray *task_list) { guint pid = 0; - Task task = { 0 }; + Task task; //while (/* read all PIDs */) { diff --git a/src/task-manager-solaris.c b/src/task-manager-solaris.c index 0afd6e0..ae0edd0 100644 --- a/src/task-manager-solaris.c +++ b/src/task-manager-solaris.c @@ -186,6 +186,7 @@ get_task_details (guint pid, Task *task) return FALSE; } + bzero(task, sizeof(Task)); task->pid = (guint)process.pr_pid; task->ppid = (guint)process.pr_ppid; g_strlcpy (task->name, process.pr_fname, sizeof(task->name)); @@ -210,7 +211,7 @@ get_task_list (GArray *task_list) GDir *dir; const gchar *name; guint pid; - Task task = { 0 }; + Task task; if ((dir = g_dir_open ("/proc", 0, NULL)) == NULL) return FALSE;