Commit 8d3e8165 authored by Tom Zanussi's avatar Tom Zanussi Committed by Steven Rostedt (VMware)
Browse files

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



Signed-off-by: default avatarTom Zanussi <zanussi@kernel.org>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent c9e759b1
Loading
Loading
Loading
Loading
+19 −11
Original line number Diff line number Diff line
@@ -23,13 +23,14 @@
#undef ERRORS
#define ERRORS	\
	C(BAD_NAME,		"Illegal name"),		\
	C(CMD_INCOMPLETE,	"Incomplete command"),		\
	C(INVALID_CMD,		"Command must be of the form: <name> field[;field] ..."),\
	C(INVALID_DYN_CMD,	"Command must be of the form: s or -:[synthetic/]<name> field[;field] ..."),\
	C(EVENT_EXISTS,		"Event already exists"),	\
	C(TOO_MANY_FIELDS,	"Too many fields"),		\
	C(INCOMPLETE_TYPE,	"Incomplete type"),		\
	C(INVALID_TYPE,		"Invalid type"),		\
	C(INVALID_FIELD,        "Invalid field"),		\
	C(CMD_TOO_LONG,		"Command too long"),
	C(INVALID_ARRAY_SPEC,	"Invalid array specification"),

#undef C
#define C(a, b)		SYNTH_ERR_##a
@@ -655,6 +656,9 @@ static struct synth_field *parse_synth_field(int argc, char **argv)

	size = synth_field_size(field->type);
	if (size < 0) {
		if (array)
			synth_err(SYNTH_ERR_INVALID_ARRAY_SPEC, errpos(field_name));
		else
			synth_err(SYNTH_ERR_INVALID_TYPE, errpos(field_type));
		ret = -EINVAL;
		goto free;
@@ -1174,7 +1178,7 @@ static int __create_synth_event(const char *name, const char *raw_fields)
	 */

	if (name[0] == '\0') {
		synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
		synth_err(SYNTH_ERR_INVALID_CMD, 0);
		return -EINVAL;
	}

@@ -1226,7 +1230,7 @@ static int __create_synth_event(const char *name, const char *raw_fields)
	}

	if (n_fields == 0) {
		synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
		synth_err(SYNTH_ERR_INVALID_CMD, 0);
		ret = -EINVAL;
		goto err;
	}
@@ -1410,13 +1414,13 @@ static int create_or_delete_synth_event(const char *raw_command)

	ret = check_command(raw_command);
	if (ret) {
		synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
		synth_err(SYNTH_ERR_INVALID_CMD, 0);
		return ret;
	}

	p = strpbrk(raw_command, " \t");
	if (!p && raw_command[0] != '!') {
		synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
		synth_err(SYNTH_ERR_INVALID_CMD, 0);
		ret = -EINVAL;
		goto free;
	}
@@ -1993,8 +1997,10 @@ static int create_synth_event(const char *raw_command)
	last_cmd_set(raw_command);

	p = strpbrk(raw_command, " \t");
	if (!p)
	if (!p) {
		synth_err(SYNTH_ERR_INVALID_CMD, 0);
		return -EINVAL;
	}

	fields = skip_spaces(p);

@@ -2007,8 +2013,10 @@ static int create_synth_event(const char *raw_command)
	/* This interface accepts group name prefix */
	if (strchr(name, '/')) {
		len = str_has_prefix(name, SYNTH_SYSTEM "/");
		if (len == 0)
		if (len == 0) {
			synth_err(SYNTH_ERR_INVALID_DYN_CMD, 0);
			return -EINVAL;
		}
		name += len;
	}

@@ -2016,7 +2024,7 @@ static int create_synth_event(const char *raw_command)

	ret = check_command(raw_command + len);
	if (ret) {
		synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
		synth_err(SYNTH_ERR_INVALID_CMD, 0);
		return ret;
	}