Messages in this thread Patch in this message | | | Date | Fri, 6 Feb 2015 13:55:19 -0500 | From | Steven Rostedt <> | Subject | Re: [RFC][PATCH v2 5/7] trace: make filter_parse_regex() provide the length of substring to compare with |
| |
On Fri, 6 Feb 2015 04:00:13 +0000 Al Viro <viro@ZenIV.linux.org.uk> wrote:
> --- 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. > */
Still needs the update to kernel doc.
> -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);
This should just add what the next patch does, instead of adding the strlen() then changing it again. The change works here as well.
- *len = strlen(*search); + *len = buff + i - *search;
It makes more sense to just add it here instead of having it changed again.
-- Steve
> > 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); > } >
| |