It's kind of strange to have check_arg() callbacks as part of the arg
objects themselves; it makes more sense to just pass these in when the
args are added instead.
Remove the check_arg() callbacks from those objects which also means
removing the check_arg() args from the init functions, adding them to
the add functions and fixing up existing callers.
Link: http://lkml.kernel.org/r/c7708d6f177fcbe1a36b6e4e8e150907df0fa5d2.1580506712.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>
* dynevent_arg_add - Add an arg to a dynevent_cmd
* @cmd: A pointer to the dynevent_cmd struct representing the new event cmd
* @arg: The argument to append to the current cmd
* dynevent_arg_add - Add an arg to a dynevent_cmd
* @cmd: A pointer to the dynevent_cmd struct representing the new event cmd
* @arg: The argument to append to the current cmd
+ * @check_arg: An (optional) pointer to a function checking arg sanity
*
* Append an argument to a dynevent_cmd. The argument string will be
* appended to the current cmd string, followed by a separator, if
*
* Append an argument to a dynevent_cmd. The argument string will be
* appended to the current cmd string, followed by a separator, if
- * applicable. Before the argument is added, the check_arg()
- * function, if defined, is called.
+ * applicable. Before the argument is added, the @check_arg function,
+ * if present, will be used to check the sanity of the current arg
+ * string.
- * The cmd string, separator, and check_arg() function should be set
- * using the dynevent_arg_init() before any arguments are added using
- * this function.
+ * The cmd string and separator should be set using the
+ * dynevent_arg_init() before any arguments are added using this
+ * function.
*
* Return: 0 if successful, error otherwise.
*/
int dynevent_arg_add(struct dynevent_cmd *cmd,
*
* Return: 0 if successful, error otherwise.
*/
int dynevent_arg_add(struct dynevent_cmd *cmd,
- struct dynevent_arg *arg)
+ struct dynevent_arg *arg,
+ dynevent_check_arg_fn_t check_arg)
{
int ret = 0;
int delta;
char *q;
{
int ret = 0;
int delta;
char *q;
- if (arg->check_arg) {
- ret = arg->check_arg(arg);
+ if (check_arg) {
+ ret = check_arg(arg);
* dynevent_arg_pair_add - Add an arg pair to a dynevent_cmd
* @cmd: A pointer to the dynevent_cmd struct representing the new event cmd
* @arg_pair: The argument pair to append to the current cmd
* dynevent_arg_pair_add - Add an arg pair to a dynevent_cmd
* @cmd: A pointer to the dynevent_cmd struct representing the new event cmd
* @arg_pair: The argument pair to append to the current cmd
+ * @check_arg: An (optional) pointer to a function checking arg sanity
*
* Append an argument pair to a dynevent_cmd. An argument pair
* consists of a left-hand-side argument and a right-hand-side
*
* Append an argument pair to a dynevent_cmd. An argument pair
* consists of a left-hand-side argument and a right-hand-side
*
* The lhs argument string will be appended to the current cmd string,
* followed by an operator, if applicable, followd by the rhs string,
*
* The lhs argument string will be appended to the current cmd string,
* followed by an operator, if applicable, followd by the rhs string,
- * followed finally by a separator, if applicable. Before anything is
- * added, the check_arg() function, if defined, is called.
+ * followed finally by a separator, if applicable. Before the
+ * argument is added, the @check_arg function, if present, will be
+ * used to check the sanity of the current arg strings.
- * The cmd strings, operator, separator, and check_arg() function
- * should be set using the dynevent_arg_pair_init() before any arguments
- * are added using this function.
+ * The cmd strings, operator, and separator should be set using the
+ * dynevent_arg_pair_init() before any arguments are added using this
+ * function.
*
* Return: 0 if successful, error otherwise.
*/
int dynevent_arg_pair_add(struct dynevent_cmd *cmd,
*
* Return: 0 if successful, error otherwise.
*/
int dynevent_arg_pair_add(struct dynevent_cmd *cmd,
- struct dynevent_arg_pair *arg_pair)
+ struct dynevent_arg_pair *arg_pair,
+ dynevent_check_arg_fn_t check_arg)
{
int ret = 0;
int delta;
char *q;
{
int ret = 0;
int delta;
char *q;
- if (arg_pair->check_arg) {
- ret = arg_pair->check_arg(arg_pair);
+ if (check_arg) {
+ ret = check_arg(arg_pair);
/**
* dynevent_arg_init - Initialize a dynevent_arg object
* @arg: A pointer to the dynevent_arg struct representing the arg
/**
* dynevent_arg_init - Initialize a dynevent_arg object
* @arg: A pointer to the dynevent_arg struct representing the arg
- * @check_arg: An (optional) pointer to a function checking arg sanity
* @separator: An (optional) separator, appended after adding the arg
*
* Initialize a dynevent_arg object. A dynevent_arg represents an
* object used to append single arguments to the current command
* @separator: An (optional) separator, appended after adding the arg
*
* Initialize a dynevent_arg object. A dynevent_arg represents an
* object used to append single arguments to the current command
- * string. The @check_arg function, if present, will be used to check
- * the sanity of the current arg string (which is directly set by the
- * caller). After the arg string is successfully appended to the
+ * string. After the arg string is successfully appended to the
* command string, the optional @separator is appended. If no
* separator was specified when initializing the arg, a space will be
* appended.
*/
void dynevent_arg_init(struct dynevent_arg *arg,
* command string, the optional @separator is appended. If no
* separator was specified when initializing the arg, a space will be
* appended.
*/
void dynevent_arg_init(struct dynevent_arg *arg,
- dynevent_check_arg_fn_t check_arg,
char separator)
{
memset(arg, '\0', sizeof(*arg));
char separator)
{
memset(arg, '\0', sizeof(*arg));
if (!separator)
separator = ' ';
arg->separator = separator;
if (!separator)
separator = ' ';
arg->separator = separator;
-
- arg->check_arg = check_arg;
}
/**
* dynevent_arg_pair_init - Initialize a dynevent_arg_pair object
* @arg_pair: A pointer to the dynevent_arg_pair struct representing the arg
}
/**
* dynevent_arg_pair_init - Initialize a dynevent_arg_pair object
* @arg_pair: A pointer to the dynevent_arg_pair struct representing the arg
- * @check_arg: An (optional) pointer to a function checking arg sanity
* @operator: An (optional) operator, appended after adding the first arg
* @separator: An (optional) separator, appended after adding the second arg
*
* @operator: An (optional) operator, appended after adding the first arg
* @separator: An (optional) separator, appended after adding the second arg
*
* variable_name;' or 'x+y' to the current command string. An
* argument pair consists of a left-hand-side argument and a
* right-hand-side argument separated by an operator, which can be
* variable_name;' or 'x+y' to the current command string. An
* argument pair consists of a left-hand-side argument and a
* right-hand-side argument separated by an operator, which can be
- * whitespace, all followed by a separator, if applicable. The
- * @check_arg function, if present, will be used to check the sanity
- * of the current arg strings (which is directly set by the caller).
- * After the first arg string is successfully appended to the command
- * string, the optional @operator is appended, followed by the second
- * arg and and optional @separator. If no separator was specified
- * when initializing the arg, a space will be appended.
+ * whitespace, all followed by a separator, if applicable. After the
+ * first arg string is successfully appended to the command string,
+ * the optional @operator is appended, followed by the second arg and
+ * and optional @separator. If no separator was specified when
+ * initializing the arg, a space will be appended.
*/
void dynevent_arg_pair_init(struct dynevent_arg_pair *arg_pair,
*/
void dynevent_arg_pair_init(struct dynevent_arg_pair *arg_pair,
- dynevent_check_arg_fn_t check_arg,
char operator, char separator)
{
memset(arg_pair, '\0', sizeof(*arg_pair));
char operator, char separator)
{
memset(arg_pair, '\0', sizeof(*arg_pair));
if (!separator)
separator = ' ';
arg_pair->separator = separator;
if (!separator)
separator = ' ';
arg_pair->separator = separator;
-
- arg_pair->check_arg = check_arg;
struct dynevent_arg {
const char *str;
char separator; /* e.g. ';', ',', or nothing */
struct dynevent_arg {
const char *str;
char separator; /* e.g. ';', ',', or nothing */
- dynevent_check_arg_fn_t check_arg;
};
extern void dynevent_arg_init(struct dynevent_arg *arg,
};
extern void dynevent_arg_init(struct dynevent_arg *arg,
- dynevent_check_arg_fn_t check_arg,
char separator);
extern int dynevent_arg_add(struct dynevent_cmd *cmd,
char separator);
extern int dynevent_arg_add(struct dynevent_cmd *cmd,
- struct dynevent_arg *arg);
+ struct dynevent_arg *arg,
+ dynevent_check_arg_fn_t check_arg);
struct dynevent_arg_pair {
const char *lhs;
const char *rhs;
char operator; /* e.g. '=' or nothing */
char separator; /* e.g. ';', ',', or nothing */
struct dynevent_arg_pair {
const char *lhs;
const char *rhs;
char operator; /* e.g. '=' or nothing */
char separator; /* e.g. ';', ',', or nothing */
- dynevent_check_arg_fn_t check_arg;
};
extern void dynevent_arg_pair_init(struct dynevent_arg_pair *arg_pair,
};
extern void dynevent_arg_pair_init(struct dynevent_arg_pair *arg_pair,
- dynevent_check_arg_fn_t check_arg,
char operator, char separator);
char operator, char separator);
extern int dynevent_arg_pair_add(struct dynevent_cmd *cmd,
extern int dynevent_arg_pair_add(struct dynevent_cmd *cmd,
- struct dynevent_arg_pair *arg_pair);
+ struct dynevent_arg_pair *arg_pair,
+ dynevent_check_arg_fn_t check_arg);
extern int dynevent_str_add(struct dynevent_cmd *cmd, const char *str);
#endif
extern int dynevent_str_add(struct dynevent_cmd *cmd, const char *str);
#endif
if (!type || !name)
return -EINVAL;
if (!type || !name)
return -EINVAL;
- dynevent_arg_pair_init(&arg_pair, synth_event_check_arg_fn, 0, ';');
+ dynevent_arg_pair_init(&arg_pair, 0, ';');
arg_pair.lhs = type;
arg_pair.rhs = name;
arg_pair.lhs = type;
arg_pair.rhs = name;
- ret = dynevent_arg_pair_add(cmd, &arg_pair);
+ ret = dynevent_arg_pair_add(cmd, &arg_pair, synth_event_check_arg_fn);
if (!type_name)
return -EINVAL;
if (!type_name)
return -EINVAL;
- dynevent_arg_init(&arg, NULL, ';');
+ dynevent_arg_init(&arg, ';');
- ret = dynevent_arg_add(cmd, &arg);
+ ret = dynevent_arg_add(cmd, &arg, NULL);
if (cmd->type != DYNEVENT_TYPE_SYNTH)
return -EINVAL;
if (cmd->type != DYNEVENT_TYPE_SYNTH)
return -EINVAL;
- dynevent_arg_init(&arg, NULL, 0);
+ dynevent_arg_init(&arg, 0);
- ret = dynevent_arg_add(cmd, &arg);
+ ret = dynevent_arg_add(cmd, &arg, NULL);
if (n_fields > SYNTH_FIELDS_MAX)
return -EINVAL;
if (n_fields > SYNTH_FIELDS_MAX)
return -EINVAL;
- dynevent_arg_init(&arg, NULL, 0);
+ dynevent_arg_init(&arg, 0);
- ret = dynevent_arg_add(cmd, &arg);
+ ret = dynevent_arg_add(cmd, &arg, NULL);
- dynevent_arg_init(&arg, NULL, 0);
+ dynevent_arg_init(&arg, 0);
- ret = dynevent_arg_add(cmd, &arg);
+ ret = dynevent_arg_add(cmd, &arg, NULL);
- ret = dynevent_arg_add(cmd, &arg);
+ ret = dynevent_arg_add(cmd, &arg, NULL);
if (cmd->type != DYNEVENT_TYPE_KPROBE)
return -EINVAL;
if (cmd->type != DYNEVENT_TYPE_KPROBE)
return -EINVAL;
- dynevent_arg_init(&arg, NULL, 0);
+ dynevent_arg_init(&arg, 0);
va_start(args, cmd);
for (;;) {
va_start(args, cmd);
for (;;) {
- ret = dynevent_arg_add(cmd, &arg);
+ ret = dynevent_arg_add(cmd, &arg, NULL);