forked from luck/tmp_suning_uos_patched
tracing: Add hist trigger error messages for sort specification
Add error codes and messages for all the error paths leading to sort specification parsing errors. Link: http://lkml.kernel.org/r/237830dc05e583fbb53664d817a784297bf961be.1561743018.git.zanussi@kernel.org Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Tom Zanussi <zanussi@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
parent
b527b638fd
commit
4de26c8c96
|
@ -66,7 +66,12 @@
|
|||
C(INVALID_SUBSYS_EVENT, "Invalid subsystem or event name"), \
|
||||
C(INVALID_REF_KEY, "Using variable references in keys not supported"), \
|
||||
C(VAR_NOT_FOUND, "Couldn't find variable"), \
|
||||
C(FIELD_NOT_FOUND, "Couldn't find field"),
|
||||
C(FIELD_NOT_FOUND, "Couldn't find field"), \
|
||||
C(EMPTY_ASSIGNMENT, "Empty assignment"), \
|
||||
C(INVALID_SORT_MODIFIER,"Invalid sort modifier"), \
|
||||
C(EMPTY_SORT_FIELD, "Empty sort field"), \
|
||||
C(TOO_MANY_SORT_FIELDS, "Too many sort fields (Max = 2)"), \
|
||||
C(INVALID_SORT_FIELD, "Sort field must be a key or a val"),
|
||||
|
||||
#undef C
|
||||
#define C(a, b) HIST_ERR_##a
|
||||
|
@ -2183,6 +2188,7 @@ parse_hist_trigger_attrs(struct trace_array *tr, char *trigger_str)
|
|||
if (rhs) {
|
||||
if (!strlen(++rhs)) {
|
||||
ret = -EINVAL;
|
||||
hist_err(tr, HIST_ERR_EMPTY_ASSIGNMENT, errpos(str));
|
||||
goto free;
|
||||
}
|
||||
ret = parse_assignment(tr, str, attrs);
|
||||
|
@ -4743,7 +4749,7 @@ static int create_hist_fields(struct hist_trigger_data *hist_data,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int is_descending(const char *str)
|
||||
static int is_descending(struct trace_array *tr, const char *str)
|
||||
{
|
||||
if (!str)
|
||||
return 0;
|
||||
|
@ -4754,11 +4760,14 @@ static int is_descending(const char *str)
|
|||
if (strcmp(str, "ascending") == 0)
|
||||
return 0;
|
||||
|
||||
hist_err(tr, HIST_ERR_INVALID_SORT_MODIFIER, errpos((char *)str));
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int create_sort_keys(struct hist_trigger_data *hist_data)
|
||||
{
|
||||
struct trace_array *tr = hist_data->event_file->tr;
|
||||
char *fields_str = hist_data->attrs->sort_key_str;
|
||||
struct tracing_map_sort_key *sort_key;
|
||||
int descending, ret = 0;
|
||||
|
@ -4782,10 +4791,12 @@ static int create_sort_keys(struct hist_trigger_data *hist_data)
|
|||
|
||||
if (!*field_str) {
|
||||
ret = -EINVAL;
|
||||
hist_err(tr, HIST_ERR_EMPTY_SORT_FIELD, errpos("sort="));
|
||||
break;
|
||||
}
|
||||
|
||||
if ((i == TRACING_MAP_SORT_KEYS_MAX - 1) && fields_str) {
|
||||
hist_err(tr, HIST_ERR_TOO_MANY_SORT_FIELDS, errpos("sort="));
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
@ -4793,11 +4804,12 @@ static int create_sort_keys(struct hist_trigger_data *hist_data)
|
|||
field_name = strsep(&field_str, ".");
|
||||
if (!field_name || !*field_name) {
|
||||
ret = -EINVAL;
|
||||
hist_err(tr, HIST_ERR_EMPTY_SORT_FIELD, errpos("sort="));
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcmp(field_name, "hitcount") == 0) {
|
||||
descending = is_descending(field_str);
|
||||
descending = is_descending(tr, field_str);
|
||||
if (descending < 0) {
|
||||
ret = descending;
|
||||
break;
|
||||
|
@ -4819,7 +4831,7 @@ static int create_sort_keys(struct hist_trigger_data *hist_data)
|
|||
|
||||
if (strcmp(field_name, test_name) == 0) {
|
||||
sort_key->field_idx = idx;
|
||||
descending = is_descending(field_str);
|
||||
descending = is_descending(tr, field_str);
|
||||
if (descending < 0) {
|
||||
ret = descending;
|
||||
goto out;
|
||||
|
@ -4830,6 +4842,7 @@ static int create_sort_keys(struct hist_trigger_data *hist_data)
|
|||
}
|
||||
if (j == hist_data->n_fields) {
|
||||
ret = -EINVAL;
|
||||
hist_err(tr, HIST_ERR_INVALID_SORT_FIELD, errpos(field_name));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user