History

tracing: Update synth command errors

Since array types are handled differently, errors referencing them also need to be handled differently. Add and use a new INVALID_ARRAY_SPEC error. Also add INVALID_CMD and INVALID_DYN_CMD to catch and display the correct form for badly-formed commands, which can also be used in place of CMD_INCOMPLETE, which is removed, and remove CMD_TOO_LONG, since it's no longer used. Link: https://lkml.kernel.org/r/b9dd434dc6458dcff11adc6ed616fe93a8794770.1612208610.git.zanussi@kernel.org

Tom Zanussi committed 5 years ago

Commit 8d3e8161 parent c9e759b1 file · +19 −11Browse files

Unified · Split

kernel/trace/trace_events_synth.c+19−11
@@ -23,13 +23,14 @@ · 22 unmodified lines
2323 #undef ERRORS
2424 #define ERRORS \
2525 C(BAD_NAME, "Illegal name"), \
26− C(CMD_INCOMPLETE, "Incomplete command"), \
26+ C(INVALID_CMD, "Command must be of the form: <name> field[;field] ..."),\
27+ C(INVALID_DYN_CMD, "Command must be of the form: s or -:[synthetic/]<name> field[;field] ..."),\
2728 C(EVENT_EXISTS, "Event already exists"), \
2829 C(TOO_MANY_FIELDS, "Too many fields"), \
2930 C(INCOMPLETE_TYPE, "Incomplete type"), \
3031 C(INVALID_TYPE, "Invalid type"), \
31− C(INVALID_FIELD, "Invalid field"), \
32− C(CMD_TOO_LONG, "Command too long"),
32+ C(INVALID_FIELD, "Invalid field"), \
33+ C(INVALID_ARRAY_SPEC, "Invalid array specification"),
3334
3435 #undef C
3536 #define C(a, b) SYNTH_ERR_##a
@@ -655,7 +656,10 @@ static struct synth_field *parse_synth_field(int argc, char **argv) · 619 unmodified lines
655656
656657 size = synth_field_size(field->type);
657658 if (size < 0) {
658− synth_err(SYNTH_ERR_INVALID_TYPE, errpos(field_type));
659+ if (array)
660+ synth_err(SYNTH_ERR_INVALID_ARRAY_SPEC, errpos(field_name));
661+ else
662+ synth_err(SYNTH_ERR_INVALID_TYPE, errpos(field_type));
659663 ret = -EINVAL;
660664 goto free;
661665 } else if (size == 0) {
@@ -1174,7 +1178,7 @@ static int __create_synth_event(const char *name, const char *raw_fields) · 512 unmodified lines
11741178 */
11751179
11761180 if (name[0] == '\0') {
1177− synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
1181+ synth_err(SYNTH_ERR_INVALID_CMD, 0);
11781182 return -EINVAL;
11791183 }
11801184
@@ -1226,7 +1230,7 @@ static int __create_synth_event(const char *name, const char *raw_fields) · 45 unmodified lines
12261230 }
12271231
12281232 if (n_fields == 0) {
1229− synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
1233+ synth_err(SYNTH_ERR_INVALID_CMD, 0);
12301234 ret = -EINVAL;
12311235 goto err;
12321236 }
@@ -1410,13 +1414,13 @@ static int create_or_delete_synth_event(const char *raw_command) · 177 unmodified lines
14101414
14111415 ret = check_command(raw_command);
14121416 if (ret) {
1413− synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
1417+ synth_err(SYNTH_ERR_INVALID_CMD, 0);
14141418 return ret;
14151419 }
14161420
14171421 p = strpbrk(raw_command, " \t");
14181422 if (!p && raw_command[0] != '!') {
1419− synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
1423+ synth_err(SYNTH_ERR_INVALID_CMD, 0);
14201424 ret = -EINVAL;
14211425 goto free;
14221426 }
@@ -1993,8 +1997,10 @@ static int create_synth_event(const char *raw_command) · 570 unmodified lines
19931997 last_cmd_set(raw_command);
19941998
19951999 p = strpbrk(raw_command, " \t");
1996− if (!p)
2000+ if (!p) {
2001+ synth_err(SYNTH_ERR_INVALID_CMD, 0);
19972002 return -EINVAL;
2003+ }
19982004
19992005 fields = skip_spaces(p);
20002006
@@ -2007,8 +2013,10 @@ static int create_synth_event(const char *raw_command) · 6 unmodified lines
20072013 /* This interface accepts group name prefix */
20082014 if (strchr(name, '/')) {
20092015 len = str_has_prefix(name, SYNTH_SYSTEM "/");
2010− if (len == 0)
2016+ if (len == 0) {
2017+ synth_err(SYNTH_ERR_INVALID_DYN_CMD, 0);
20112018 return -EINVAL;
2019+ }
20122020 name += len;
20132021 }
20142022
@@ -2016,7 +2024,7 @@ static int create_synth_event(const char *raw_command) · 1 unmodified line
20162024
20172025 ret = check_command(raw_command + len);
20182026 if (ret) {
2019− synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
2027+ synth_err(SYNTH_ERR_INVALID_CMD, 0);
20202028 return ret;
20212029 }
20222030

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t