perf kmem: Use memdup()
Commit-ID: 8d9233f205e8855dc762665e28012354cd46af45 Gitweb: http://git.kernel.org/tip/8d9233f205e8855dc762665e28012354cd46af45 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Thu, 24 Jan 2013 22:24:57 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 25 Jan 2013 12:49:28 -0300
perf kmem: Use memdup()
Instead of hand coded equivalent.
Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/builtin-kmem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/builtin-kmem.c +3 -3
@@ -17,6 +17,7 @@#include "util/debug.h" #include <linux/rbtree.h> +#include <linux/string.h> struct alloc_stat ;typedef int (*sort_fn_t )(struct alloc_stat *,struct alloc_stat *);
@@ -618,12 +619,11 @@ static int sort_dimension__add(const char *tok, struct list_head *list)for (i =0 ; i <NUM_AVAIL_SORTS ; i++) {if (!strcmp (avail_sorts[i]->name, tok)) { - sort =malloc (sizeof (*sort)); + sort =memdup (avail_sorts[i],sizeof (*avail_sorts[i]));if (!sort) { -pr_err ("%s: malloc failed\n" , __func__); +pr_err ("%s: memdup failed\n" , __func__);return -1 ; } -memcpy (sort, avail_sorts[i],sizeof (*sort));list_add_tail (&sort->list, list);return 0 ; }