From 993ef78b817ac3d6758f8e02d699ea1913c9c691 Mon Sep 17 00:00:00 2001 From: Landry Breuil Date: Sun, 3 Jun 2018 17:56:31 +0200 Subject: [PATCH] Switch back all bzero() calls to use memset() Even if it's uglier to use memset, bzero seems deprecated. --- src/process-tree-model.c | 4 ++-- src/task-manager-bsd.c | 6 +++--- src/task-manager-freebsd.c | 4 ++-- src/task-manager-linux.c | 2 +- src/task-manager-skel.c | 2 +- src/task-manager-solaris.c | 2 +- src/task-manager.c | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/process-tree-model.c b/src/process-tree-model.c index fdc8c2a..b7bb82c 100644 --- a/src/process-tree-model.c +++ b/src/process-tree-model.c @@ -465,7 +465,7 @@ xtm_process_tree_model_row_changed (XtmProcessTreeModel *treemodel, GtkTreePath s_iter.user_data3 = NULL; /* Use the root entry as fall-back if no parent could be found */ - bzero(&found, sizeof(found)); + memset(&found, 0, sizeof(found)); found.parent = treemodel->tree; found.treemodel = treemodel; gtk_tree_model_get_value (model, iter, treemodel->p_column, &found.p_value); @@ -643,7 +643,7 @@ xtm_process_tree_model_row_inserted (XtmProcessTreeModel *treemodel, GtkTreePath g_sequence_foreach_range (g_sequence_iter_next (lnk->list), g_sequence_get_end_iter (treemodel->list), do_path, (gpointer)gtk_tree_path_next); - bzero(&found, sizeof(found)); + memset(&found, 0, sizeof(found)); found.parent = treemodel->tree; found.treemodel = treemodel; gtk_tree_model_get_value (model, iter, treemodel->p_column, &found.p_value); diff --git a/src/task-manager-bsd.c b/src/task-manager-bsd.c index 8094332..cf46041 100644 --- a/src/task-manager-bsd.c +++ b/src/task-manager-bsd.c @@ -99,7 +99,7 @@ gboolean get_task_list (GArray *task_list) #else struct kinfo_proc2 p = kp[i]; #endif - bzero(&t, sizeof(t)); + memset(&t, 0, sizeof(t)); t.pid = p.p_pid; t.ppid = p.p_ppid; t.uid = p.p_uid; @@ -114,11 +114,11 @@ gboolean get_task_list (GArray *task_list) size = 1024; if ((args = malloc(size)) == NULL) errx(1,"failed to allocate memory for argv structures at %zu", size); - bzero(args, size); + memset(args, 0, 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); - bzero(args, size); + memset(args, 0, size); mib[0] = CTL_KERN; mib[1] = KERN_PROC_ARGS; mib[2] = t.pid; diff --git a/src/task-manager-freebsd.c b/src/task-manager-freebsd.c index c4d985f..3a96814 100644 --- a/src/task-manager-freebsd.c +++ b/src/task-manager-freebsd.c @@ -135,7 +135,7 @@ get_task_details (struct kinfo_proc *kp, Task *task) size_t bufsz; int i, oid[4]; - bzero(task, sizeof(Task)); + memset(task, 0, sizeof(Task)); task->pid = kp->ki_pid; task->ppid = kp->ki_ppid; task->cpu_user = 100.0f * ((float)kp->ki_pctcpu / FSCALE); @@ -151,7 +151,7 @@ get_task_details (struct kinfo_proc *kp, Task *task) oid[2] = KERN_PROC_ARGS; oid[3] = kp->ki_pid; bufsz = sizeof(buf); - bzero(buf, sizeof(buf)); + memset(buf, 0, sizeof(buf)); if (sysctl(oid, 4, buf, &bufsz, 0, 0) == -1) { /* * If the supplied buf is too short to hold the requested diff --git a/src/task-manager-linux.c b/src/task-manager-linux.c index 441a234..e815185 100644 --- a/src/task-manager-linux.c +++ b/src/task-manager-linux.c @@ -208,7 +208,7 @@ get_task_details (GPid pid, Task *task) } fclose (file); - bzero(task, sizeof(Task)); + memset(task, 0, sizeof(Task)); /* Scanning the short process name is unreliable with scanf when it contains * spaces, retrieve it manually and fill the buffer */ diff --git a/src/task-manager-skel.c b/src/task-manager-skel.c index cfca284..7088fe5 100644 --- a/src/task-manager-skel.c +++ b/src/task-manager-skel.c @@ -49,7 +49,7 @@ get_cpu_usage (gushort *cpu_count, gfloat *cpu_user, gfloat *cpu_system) static gboolean get_task_details (GPid pid, Task *task) { - bzero(task, sizeof(Task)); + memset(task, 0, 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"); diff --git a/src/task-manager-solaris.c b/src/task-manager-solaris.c index 37279b0..a8df96c 100644 --- a/src/task-manager-solaris.c +++ b/src/task-manager-solaris.c @@ -184,7 +184,7 @@ get_task_details (GPid pid, Task *task) return FALSE; } - bzero(task, sizeof(Task)); + memset(task, 0, sizeof(Task)); task->pid = process.pr_pid; task->ppid = process.pr_ppid; g_strlcpy (task->name, process.pr_fname, sizeof(task->name)); diff --git a/src/task-manager.c b/src/task-manager.c index 8c4ceaf..93f9122 100644 --- a/src/task-manager.c +++ b/src/task-manager.c @@ -481,7 +481,7 @@ get_uid_name (guint uid) struct passwd *pw = NULL, pwd_buf; char buf[4096]; - bzero(buf, sizeof(buf)); + memset(buf, 0, sizeof(buf)); error = getpwuid_r(uid, &pwd_buf, buf, sizeof(buf), &pw); return (g_strdup ((0 == error && pw != NULL) ? pw->pw_name : "nobody"));