Re: [PATCH] dynamic_debug: add wildcard support to filterfiles/functions/modules

From: Joe Perches
Date: Thu Jul 25 2013 - 12:47:28 EST


On Thu, 2013-07-25 at 21:02 +0800, Du, Changbin wrote:
> From: "Du, Changbin" <changbin.du@xxxxxxxxx>
>
> This patch add wildcard '*'(matches zero or more characters) and '?'
> (matches one character) support when qurying debug flags.

Seems very useful. Caveat below.

> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
[]
> @@ -127,6 +127,21 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg)
> query->first_lineno, query->last_lineno);
> }
>
> +static int match_pattern(char *pat, char *str)
> +{
> + switch (*pat) {
> + case '\0':
> + return !*str;
> + case '*':
> + return match_pattern(pat+1, str) ||
> + (*str && match_pattern(pat, str+1));
> + case '?':
> + return *str && match_pattern(pat+1, str+1);
> + default:
> + return *pat == *str && match_pattern(pat+1, str 1);
> + }
> +}

What's the maximum length string used today?
On a very long pattern, can this recursion cause stack overflow?

Other than that, I like it.


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