[RFC][PATCH v2 4/7] ftrace: switch matching to memcmp() and memmem()

From: Al Viro
Date: Thu Feb 05 2015 - 23:01:22 EST


From: Al Viro <viro@xxxxxxxxxxxxxxxxxx>

now we don't need the glob substring being matched to get
NUL-terminated by filter_parse_regex()

Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
---
kernel/trace/ftrace.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 67ecd14..a369a54 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3365,24 +3365,26 @@ ftrace_notrace_open(struct inode *inode, struct file *file)
static int ftrace_match(char *str, char *regex, int len, int type)
{
int matched = 0;
- int slen;
+ int slen = strlen(str);
+
+ if (slen < len)
+ return 0;

switch (type) {
case MATCH_FULL:
- if (strcmp(str, regex) == 0)
+ if (slen == len && memcmp(str, regex, len) == 0)
matched = 1;
break;
case MATCH_FRONT_ONLY:
- if (strncmp(str, regex, len) == 0)
+ if (memcmp(str, regex, len) == 0)
matched = 1;
break;
case MATCH_MIDDLE_ONLY:
- if (strstr(str, regex))
+ if (memmem(str, slen, regex, len))
matched = 1;
break;
case MATCH_END_ONLY:
- slen = strlen(str);
- if (slen >= len && memcmp(str + slen - len, regex, len) == 0)
+ if (memcmp(str + slen - len, regex, len) == 0)
matched = 1;
break;
}
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/