[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <51F73A17.2090208@akamai.com>
Date: Mon, 29 Jul 2013 23:59:19 -0400
From: Jason Baron <jbaron@...mai.com>
To: Joe Perches <joe@...ches.com>
CC: "Du, Changbin" <changbin.du@...il.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] dynamic_debug: add wildcard support to filter files/functions/modules
On 07/25/2013 12:47 PM, Joe Perches wrote:
> On Thu, 2013-07-25 at 21:02 +0800, Du, Changbin wrote:
>> From: "Du, Changbin" <changbin.du@...il.com>
>>
>> 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.
The recursion here is a concern - especially since the 'pat' pointer is
controlled from userspace. Maybe not at pretty, but this can easily be
done in userspace. For example, to set all driver/usb* one could do
something like:
grep "drivers/usb" control | awk -F ":| " '{ print "file " $1 " line "
$2 }' | xargs -i -n1 echo {} +p > control
Thanks,
-Jason
--
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