On Wed, 8 Feb 2017 11:24:57 -0600 Tom Zanussi <tom.zanussi@xxxxxxxxxxxxxxx> wrote: > In preparation for hist_fields that won't be strictly based on > trace_event_fields, add a new hist_field_name() accessor to allow that > flexibility and update associated users. > > Signed-off-by: Tom Zanussi <tom.zanussi@xxxxxxxxxxxxxxx> > --- > kernel/trace/trace_events_hist.c | 59 +++++++++++++++++++++++++--------------- > 1 file changed, 37 insertions(+), 22 deletions(-) > > diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c > index f3a960e..37347d7 100644 > --- a/kernel/trace/trace_events_hist.c > +++ b/kernel/trace/trace_events_hist.c > @@ -145,6 +145,16 @@ struct hist_trigger_data { > struct tracing_map *map; > }; > > +static const char *hist_field_name(struct hist_field *field) > +{ > + const char *field_name = NULL; > + > + if (field->field) > + field_name = field->field->name; > + > + return field_name; > +} It would be much simpler to do: { if (field->field) return field->field->name; return NULL; } or even: return field->field ? field->field->name : NULL; > + > static hist_field_fn_t select_value_fn(int field_size, int field_is_signed) > { > hist_field_fn_t fn = NULL; > @@ -652,7 +662,6 @@ static int is_descending(const char *str) > static int create_sort_keys(struct hist_trigger_data *hist_data) > { > char *fields_str = hist_data->attrs->sort_key_str; > - struct ftrace_event_field *field = NULL; > struct tracing_map_sort_key *sort_key; > int descending, ret = 0; > unsigned int i, j; > @@ -669,7 +678,9 @@ static int create_sort_keys(struct hist_trigger_data *hist_data) > } > > for (i = 0; i < TRACING_MAP_SORT_KEYS_MAX; i++) { > + struct hist_field *hist_field; > char *field_str, *field_name; > + const char *test_name; > > sort_key = &hist_data->sort_keys[i]; > > @@ -702,8 +713,9 @@ static int create_sort_keys(struct hist_trigger_data *hist_data) > } > > for (j = 1; j < hist_data->n_fields; j++) { > - field = hist_data->fields[j]->field; > - if (field && (strcmp(field_name, field->name) == 0)) { > + hist_field = hist_data->fields[j]; > + test_name = hist_field_name(hist_field); > + if (strcmp(field_name, test_name) == 0) { If hist_field_name() returns NULL, the strcmp() will crash. > sort_key->field_idx = j; > descending = is_descending(field_str); > if (descending < 0) { > @@ -951,6 +963,7 @@ static void hist_trigger_stacktrace_print(struct seq_file *m, > struct hist_field *key_field; > char str[KSYM_SYMBOL_LEN]; > bool multiline = false; > + const char *field_name; > unsigned int i; > u64 uval; > -- Steve -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html