Re: [RFC][PATCH v2 5/7] trace: make filter_parse_regex() provide the length of substring to compare with

From: Steven Rostedt
Date: Fri Feb 06 2015 - 13:55:27 EST


On Fri, 6 Feb 2015 04:00:13 +0000
Al Viro <viro@xxxxxxxxxxxxxxxxxx> 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, &not);
> - r->len = strlen(search);
> + type = filter_parse_regex(r->pattern, &r->len, &search, &not);
> memmove(r->pattern, search, r->len+1);
> }
>

--
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/