Skip to content

Commit 80042c8

Browse files
andy-shevrostedt
authored andcommitted
tracing: Use generic type for comparator function
Comparator function type, cmp_func_t, is defined in the types.h, use it in the code. Link: http://lkml.kernel.org/r/20191007135656.37734-3-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent e8877ec commit 80042c8

4 files changed

Lines changed: 13 additions & 15 deletions

File tree

‎kernel/trace/ftrace.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,10 @@ static void *function_stat_start(struct tracer_stat *trace)
465465

466466
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
467467
/* function graph compares on total time */
468-
static int function_stat_cmp(void *p1, void *p2)
468+
static int function_stat_cmp(const void *p1, const void *p2)
469469
{
470-
struct ftrace_profile *a = p1;
471-
struct ftrace_profile *b = p2;
470+
const struct ftrace_profile *a = p1;
471+
const struct ftrace_profile *b = p2;
472472

473473
if (a->time < b->time)
474474
return -1;
@@ -479,10 +479,10 @@ static int function_stat_cmp(void *p1, void *p2)
479479
}
480480
#else
481481
/* not function graph compares against hits */
482-
static int function_stat_cmp(void *p1, void *p2)
482+
static int function_stat_cmp(const void *p1, const void *p2)
483483
{
484-
struct ftrace_profile *a = p1;
485-
struct ftrace_profile *b = p2;
484+
const struct ftrace_profile *a = p1;
485+
const struct ftrace_profile *b = p2;
486486

487487
if (a->counter < b->counter)
488488
return -1;

‎kernel/trace/trace_branch.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ static int annotated_branch_stat_headers(struct seq_file *m)
244244
return 0;
245245
}
246246

247-
static inline long get_incorrect_percent(struct ftrace_branch_data *p)
247+
static inline long get_incorrect_percent(const struct ftrace_branch_data *p)
248248
{
249249
long percent;
250250

@@ -332,10 +332,10 @@ annotated_branch_stat_next(void *v, int idx)
332332
return p;
333333
}
334334

335-
static int annotated_branch_stat_cmp(void *p1, void *p2)
335+
static int annotated_branch_stat_cmp(const void *p1, const void *p2)
336336
{
337-
struct ftrace_branch_data *a = p1;
338-
struct ftrace_branch_data *b = p2;
337+
const struct ftrace_branch_data *a = p1;
338+
const struct ftrace_branch_data *b = p2;
339339

340340
long percent_a, percent_b;
341341

‎kernel/trace/trace_stat.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ static void destroy_session(struct stat_session *session)
7272
kfree(session);
7373
}
7474

75-
typedef int (*cmp_stat_t)(void *, void *);
76-
77-
static int insert_stat(struct rb_root *root, void *stat, cmp_stat_t cmp)
75+
static int insert_stat(struct rb_root *root, void *stat, cmp_func_t cmp)
7876
{
7977
struct rb_node **new = &(root->rb_node), *parent = NULL;
8078
struct stat_node *data;
@@ -112,7 +110,7 @@ static int insert_stat(struct rb_root *root, void *stat, cmp_stat_t cmp)
112110
* This one will force an insertion as right-most node
113111
* in the rbtree.
114112
*/
115-
static int dummy_cmp(void *p1, void *p2)
113+
static int dummy_cmp(const void *p1, const void *p2)
116114
{
117115
return -1;
118116
}

‎kernel/trace/trace_stat.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct tracer_stat {
1616
void *(*stat_start)(struct tracer_stat *trace);
1717
void *(*stat_next)(void *prev, int idx);
1818
/* Compare two entries for stats sorting */
19-
int (*stat_cmp)(void *p1, void *p2);
19+
cmp_func_t stat_cmp;
2020
/* Print a stat entry */
2121
int (*stat_show)(struct seq_file *s, void *p);
2222
/* Release an entry */

0 commit comments

Comments
 (0)