Skip to content

Commit

Permalink
perf tools: Fix calloc argument ordering
Browse files Browse the repository at this point in the history
A sweep of the kernel for regex "kcalloc(sizeof" turned up 2 reversed
args, fixed in commit d3d09e1 ("EDAC:
Fix kcalloc argument order") and also fixed in the networking commit
a1b1add ("gro: Fix kcalloc argument
order").

I know that was the regex used, because on seeing the 1st of these
changes, I wondered "how many other instances of this are there" and I
happened to just use "calloc(sizeof" as a regex and it in turn found
these additional reversed args instances in the perf code.

In the kcalloc cases, the changes are cosmetic, since the numbers are
simply multiplied.  I had no desire to go data mining in userspace to
see if the same thing held true there, however.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Joe Perches <joe@perches.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1359594349-25912-1-git-send-email-paul.gortmaker@windriver.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Paul Gortmaker authored and Arnaldo Carvalho de Melo committed Feb 6, 2013
1 parent 5a30a99 commit 91b9880
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tools/perf/util/callchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ int callchain_cursor_append(struct callchain_cursor *cursor,
struct callchain_cursor_node *node = *cursor->last;

if (!node) {
node = calloc(sizeof(*node), 1);
node = calloc(1, sizeof(*node));
if (!node)
return -ENOMEM;

Expand Down
4 changes: 2 additions & 2 deletions tools/perf/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -2253,7 +2253,7 @@ static int perf_header__adds_write(struct perf_header *header,
if (!nr_sections)
return 0;

feat_sec = p = calloc(sizeof(*feat_sec), nr_sections);
feat_sec = p = calloc(nr_sections, sizeof(*feat_sec));
if (feat_sec == NULL)
return -ENOMEM;

Expand Down Expand Up @@ -2425,7 +2425,7 @@ int perf_header__process_sections(struct perf_header *header, int fd,
if (!nr_sections)
return 0;

feat_sec = sec = calloc(sizeof(*feat_sec), nr_sections);
feat_sec = sec = calloc(nr_sections, sizeof(*feat_sec));
if (!feat_sec)
return -1;

Expand Down

0 comments on commit 91b9880

Please sign in to comment.