mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-17 22:28:12 +07:00
tracing: Embed replace_filter_string() helper function
The replace_filter_string() frees the current string and then copies a given string. But in the two locations that it was used, the allocation happened right after the filter was allocated (nothing to replace). There's no need for this to be a helper function. Embedding the allocation in the two places where it was called will make changing the code in the future easier. Also make the variable consistent (always use "filter_string" as the name, as it was used in one instance as "filter_str") Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
parent
404a3add43
commit
567f6989fd
@ -664,17 +664,6 @@ static void remove_filter_string(struct event_filter *filter)
|
|||||||
filter->filter_string = NULL;
|
filter->filter_string = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int replace_filter_string(struct event_filter *filter,
|
|
||||||
char *filter_string)
|
|
||||||
{
|
|
||||||
kfree(filter->filter_string);
|
|
||||||
filter->filter_string = kstrdup(filter_string, GFP_KERNEL);
|
|
||||||
if (!filter->filter_string)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void append_filter_err(struct filter_parse_state *ps,
|
static void append_filter_err(struct filter_parse_state *ps,
|
||||||
struct event_filter *filter)
|
struct event_filter *filter)
|
||||||
{
|
{
|
||||||
@ -1802,9 +1791,8 @@ static int replace_system_preds(struct trace_subsystem_dir *dir,
|
|||||||
if (!filter)
|
if (!filter)
|
||||||
goto fail_mem;
|
goto fail_mem;
|
||||||
|
|
||||||
/* Can only fail on no memory */
|
filter->filter_string = kstrdup(filter_string, GFP_KERNEL);
|
||||||
err = replace_filter_string(filter, filter_string);
|
if (!filter->filter_string)
|
||||||
if (err)
|
|
||||||
goto fail_mem;
|
goto fail_mem;
|
||||||
|
|
||||||
err = replace_preds(file->event_call, filter, ps, false);
|
err = replace_preds(file->event_call, filter, ps, false);
|
||||||
@ -1868,7 +1856,7 @@ static int replace_system_preds(struct trace_subsystem_dir *dir,
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int create_filter_start(char *filter_str, bool set_str,
|
static int create_filter_start(char *filter_string, bool set_str,
|
||||||
struct filter_parse_state **psp,
|
struct filter_parse_state **psp,
|
||||||
struct event_filter **filterp)
|
struct event_filter **filterp)
|
||||||
{
|
{
|
||||||
@ -1880,8 +1868,11 @@ static int create_filter_start(char *filter_str, bool set_str,
|
|||||||
|
|
||||||
/* allocate everything, and if any fails, free all and fail */
|
/* allocate everything, and if any fails, free all and fail */
|
||||||
filter = kzalloc(sizeof(*filter), GFP_KERNEL);
|
filter = kzalloc(sizeof(*filter), GFP_KERNEL);
|
||||||
if (filter && set_str)
|
if (filter && set_str) {
|
||||||
err = replace_filter_string(filter, filter_str);
|
filter->filter_string = kstrdup(filter_string, GFP_KERNEL);
|
||||||
|
if (!filter->filter_string)
|
||||||
|
err = -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
ps = kzalloc(sizeof(*ps), GFP_KERNEL);
|
ps = kzalloc(sizeof(*ps), GFP_KERNEL);
|
||||||
|
|
||||||
@ -1895,7 +1886,7 @@ static int create_filter_start(char *filter_str, bool set_str,
|
|||||||
*filterp = filter;
|
*filterp = filter;
|
||||||
*psp = ps;
|
*psp = ps;
|
||||||
|
|
||||||
parse_init(ps, filter_ops, filter_str);
|
parse_init(ps, filter_ops, filter_string);
|
||||||
err = filter_parse(ps);
|
err = filter_parse(ps);
|
||||||
if (err && set_str)
|
if (err && set_str)
|
||||||
append_filter_err(ps, filter);
|
append_filter_err(ps, filter);
|
||||||
|
Loading…
Reference in New Issue
Block a user