[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1423195215-25134-4-git-send-email-viro@ZenIV.linux.org.uk>
Date: Fri, 6 Feb 2015 04:00:12 +0000
From: Al Viro <viro@...IV.linux.org.uk>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: linux-kernel@...r.kernel.org
Subject: [RFC][PATCH v2 4/7] ftrace: switch matching to memcmp() and memmem()
From: Al Viro <viro@...iv.linux.org.uk>
now we don't need the glob substring being matched to get
NUL-terminated by filter_parse_regex()
Signed-off-by: Al Viro <viro@...iv.linux.org.uk>
---
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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists