lkml.org 
[lkml]   [2013]   [Oct]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3] dynamic_debug: add wildcard support to filter files/functions/modules
From
Date
On Tue, 2013-10-29 at 21:33 +0800, Du, Changbin wrote:
> This patch add wildcard '*'(matches zero or more characters) and '?'
> (matches one character) support when qurying debug flags.

Hi again. Some trivial notes and a possible logic error:

> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
[]
> @@ -127,6 +127,43 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg)
> query->first_lineno, query->last_lineno);
> }
>
> +/* check if the string matches given pattern which includes wildcards */
> +static bool match_pattern(const char *pattern, const char *string)
> +{
> + const char *s = string,
> + *p = pattern;

This sort of alignment is pretty unusual.
Most kernel uses just repeat the type like:

const char *s = string;
const char *p = pattern;

> + bool star = 0;

bool star = false;

> +
> + while (*s) {
> + switch (*p) {
> + case '?':
> + ++s, ++p;
> + break;
> + case '*':
> + star = true;
> + string = s;
> + if (!*++p)
> + return true;
> + pattern = p;;

repeated ;
Running your patches through checkpatch should find
this sort of defect.

> + break;
> + default:
> + if (*s != *p) {
> + if (!star)
> + return false;
> + string++;
> + s = string;
> + p = pattern;
> + break;
> + }
> + ++s, ++p;

Maybe nicer with an if/else, I think you're still
missing a reset of "star = false;" and I also think
it's better to use a break here too.

if (*s == *p) {
s++;
p++;
star = false;
} else {
if (!star)
return false;
string++;
s = string;
p = pattern;
}
break;





\
 
 \ /
  Last update: 2013-10-29 17:41    [W:0.138 / U:5.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site