LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org
Subject: [RFC][PATCH 5/7] trace: make filter_parse_regex() provide the length of substring to compare with
Date: Thu, 5 Feb 2015 19:56:38 +0000 [thread overview]
Message-ID: <1423166200-1800-5-git-send-email-viro@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20150205194914.GR29656@ZenIV.linux.org.uk>
From: Al Viro <viro@zeniv.linux.org.uk>
... by passing len by address and using it to report the length of
substring in question.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
kernel/trace/ftrace.c | 24 +++++++++---------------
kernel/trace/trace.h | 2 +-
kernel/trace/trace_events_filter.c | 10 +++++-----
3 files changed, 15 insertions(+), 21 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 6cb104a..e082681 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3441,7 +3441,6 @@ static int
match_records(struct ftrace_hash *hash, char *buff,
int len, char *mod, int not)
{
- unsigned search_len = 0;
struct ftrace_page *pg;
struct dyn_ftrace *rec;
int type = MATCH_FULL;
@@ -3449,10 +3448,8 @@ match_records(struct ftrace_hash *hash, char *buff,
int found = 0;
int ret;
- if (len) {
- type = filter_parse_regex(buff, len, &search, ¬);
- search_len = strlen(search);
- }
+ if (len)
+ type = filter_parse_regex(buff, &len, &search, ¬);
mutex_lock(&ftrace_lock);
@@ -3460,7 +3457,7 @@ match_records(struct ftrace_hash *hash, char *buff,
goto out_unlock;
do_for_each_ftrace_rec(pg, rec) {
- if (ftrace_match_record(rec, mod, search, search_len, type)) {
+ if (ftrace_match_record(rec, mod, search, len, type)) {
ret = enter_record(hash, rec, not);
if (ret < 0) {
found = ret;
@@ -3648,14 +3645,13 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
struct ftrace_hash *hash;
struct ftrace_page *pg;
struct dyn_ftrace *rec;
- int type, len, not;
+ int type, len = strlen(glob), not;
unsigned long key;
int count = 0;
char *search;
int ret;
- type = filter_parse_regex(glob, strlen(glob), &search, ¬);
- len = strlen(search);
+ type = filter_parse_regex(glob, &len, &search, ¬);
/* we do not support '!' for function probes */
if (WARN_ON(not))
@@ -3770,9 +3766,9 @@ __unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
glob = NULL;
else if (glob) {
int not;
+ len = strlen(glob);
- type = filter_parse_regex(glob, strlen(glob), &search, ¬);
- len = strlen(search);
+ type = filter_parse_regex(glob, &len, &search, ¬);
/* we do not support '!' for function probes */
if (WARN_ON(not))
@@ -4551,7 +4547,7 @@ ftrace_set_func(unsigned long *array, int *idx, int size, char *buffer)
{
struct dyn_ftrace *rec;
struct ftrace_page *pg;
- int search_len;
+ int search_len = strlen(buffer);
int fail = 1;
int type, not;
char *search;
@@ -4559,12 +4555,10 @@ ftrace_set_func(unsigned long *array, int *idx, int size, char *buffer)
int i;
/* decode regex */
- type = filter_parse_regex(buffer, strlen(buffer), &search, ¬);
+ type = filter_parse_regex(buffer, &search_len, &search, ¬);
if (!not && *idx >= size)
return -EBUSY;
- search_len = strlen(search);
-
mutex_lock(&ftrace_lock);
if (unlikely(ftrace_disabled)) {
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 8de48ba..7483205 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1051,7 +1051,7 @@ struct filter_pred {
};
extern enum regex_type
-filter_parse_regex(char *buff, int len, char **search, int *not);
+filter_parse_regex(char *buff, int *len, char **search, int *not);
extern void print_event_filter(struct ftrace_event_file *file,
struct trace_seq *s);
extern int apply_event_filter(struct ftrace_event_file *file,
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 6c4a96b..6a659e1 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -321,7 +321,7 @@ static int regex_match_end(char *str, struct regex *r, int len)
* not returns 1 if buff started with a '!'
* 0 otherwise.
*/
-enum regex_type filter_parse_regex(char *buff, int len, char **search, int *not)
+enum regex_type filter_parse_regex(char *buff, int *len, char **search, int *not)
{
int type = MATCH_FULL;
int i;
@@ -329,13 +329,13 @@ enum regex_type filter_parse_regex(char *buff, int len, char **search, int *not)
if (buff[0] == '!') {
*not = 1;
buff++;
- len--;
+ (*len)--;
} else
*not = 0;
*search = buff;
- for (i = 0; i < len; i++) {
+ for (i = 0; i < *len; i++) {
if (buff[i] == '*') {
if (!i) {
*search = buff + 1;
@@ -350,6 +350,7 @@ enum regex_type filter_parse_regex(char *buff, int len, char **search, int *not)
}
}
}
+ *len = strlen(*search);
return type;
}
@@ -362,8 +363,7 @@ static void filter_build_regex(struct filter_pred *pred)
int not = 0;
if (pred->op == OP_GLOB) {
- type = filter_parse_regex(r->pattern, r->len, &search, ¬);
- r->len = strlen(search);
+ type = filter_parse_regex(r->pattern, &r->len, &search, ¬);
memmove(r->pattern, search, r->len+1);
}
--
2.1.4
next prev parent reply other threads:[~2015-02-05 19:57 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-05 19:49 [RFC][PATCHES] constifying ftrace globs Al Viro
2015-02-05 19:56 ` [RFC][PATCH 1/7] trace: fix the glob match in __unregister_ftrace_function_probe() Al Viro
2015-02-05 20:43 ` Steven Rostedt
2015-02-05 22:30 ` Al Viro
2015-02-05 22:52 ` Steven Rostedt
2015-02-05 19:56 ` [RFC][PATCH 2/7] implement memmem() Al Viro
2015-02-05 19:56 ` [RFC][PATCH 3/7] trace_events_filter.c: switch to memcmp() and memmem() for matching Al Viro
2015-02-05 19:56 ` [RFC][PATCH 4/7] ftrace: switch matching to memcmp() and memmem() Al Viro
2015-02-05 19:56 ` Al Viro [this message]
2015-02-05 21:29 ` [RFC][PATCH 5/7] trace: make filter_parse_regex() provide the length of substring to compare with Steven Rostedt
2015-02-05 21:44 ` Al Viro
2015-02-05 22:07 ` Steven Rostedt
2015-02-05 22:46 ` Al Viro
2015-02-06 4:00 ` [RFC][PATCH v2 1/7] trace: fix the glob match in __unregister_ftrace_function_probe() Al Viro
2015-02-06 4:00 ` [RFC][PATCH v2 2/7] implement memmem() Al Viro
2015-02-06 16:19 ` Steven Rostedt
2015-02-06 22:30 ` Rasmus Villemoes
2015-02-06 22:55 ` Steven Rostedt
2015-02-06 23:14 ` Rasmus Villemoes
2015-02-06 4:00 ` [RFC][PATCH v2 3/7] trace_events_filter.c: switch to memcmp() and memmem() for matching Al Viro
2015-02-06 16:24 ` Steven Rostedt
2015-02-06 4:00 ` [RFC][PATCH v2 4/7] ftrace: switch matching to memcmp() and memmem() Al Viro
2015-02-06 4:00 ` [RFC][PATCH v2 5/7] trace: make filter_parse_regex() provide the length of substring to compare with Al Viro
2015-02-06 18:55 ` Steven Rostedt
2015-02-06 4:00 ` [RFC][PATCH v2 6/7] trace: constify filter_parse_regex(), match_records(), ftrace_match() and ftrace_match_record() Al Viro
2015-02-06 18:56 ` Steven Rostedt
2015-02-06 4:00 ` [RFC][PATCH v2 7/7] trace: constify glob arguments all way up to ftrace_function_set_regexp() Al Viro
2015-02-05 19:56 ` [RFC][PATCH 6/7] trace: constify filter_parse_regex(), match_records(), ftrace_match() and ftrace_match_record() Al Viro
2015-02-05 21:31 ` Steven Rostedt
2015-02-05 19:56 ` [RFC][PATCH 7/7] trace: constify glob arguments all way up to ftrace_function_set_regexp() Al Viro
2020-01-24 23:45 ` [RFC][PATCHES] constifying ftrace globs Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1423166200-1800-5-git-send-email-viro@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--subject='Re: [RFC][PATCH 5/7] trace: make filter_parse_regex() provide the length of substring to compare with' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).