lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1382977811.30941.33.camel@joe-AO722>
Date:	Mon, 28 Oct 2013 09:30:11 -0700
From:	Joe Perches <joe@...ches.com>
To:	"Du, Changbin" <changbin.du@...il.com>
Cc:	jbaron@...mai.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] dynamic_debug: add wildcard support to filter
 files/functions/modules

On Mon, 2013-10-28 at 23:29 +0800, Du, Changbin wrote:
> From: "Du, Changbin" <changbin.du@...il.com>

trivial notes:

> This patch add wildcard '*'(matches zero or more characters) and '?'
> (matches one character) support when qurying debug flags.

> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
[]
> @@ -127,6 +127,41 @@ 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 int match_pattern(const char *pattern, const char *string)

bool match_pattern

> +{
> +	const char *s, *p;
> +	int star = 0;

bool star = false;

> +
> +loop:
> +	for (s = string, p = pattern; *s; ++s, ++p) {
> +		switch (*p) {
> +		case '?':
> +			break;
> +		case '*':
> +			star = 1;
> +			string = s;
> +			pattern = p;
> +			if (!*++pattern)
> +				return 1;
> +			goto loop;
> +		default:
> +			if (*s != *p)
> +				goto star_check;

			star = false;

> +			break;
> +		}
> +	}
> +	if (*p == '*')
> +		++p;
> +	return (!*p);

Don't need parentheses.

> +
> +star_check:
> +	if (!star)
> +		return 0;
> +	string++;
> +	goto loop;
> +}

The star_check: label block seems like it'd be
better in the switch case as it's only used once.

Maybe the thing would be more readable with a
while loop

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

Powered by Openwall GNU/*/Linux Powered by OpenVZ