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: <1373984501.4513.8.camel@chaos.site>
Date:	Tue, 16 Jul 2013 16:21:41 +0200
From:	Jean Delvare <jdelvare@...e.de>
To:	"Yann E. MORIN" <yann.morin.1998@...e.fr>
Cc:	linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
	Michal Marek <mmarek@...e.cz>
Subject: Re: [PATCH 2/3] kconfig: avoid multiple calls to strlen

Le Saturday 13 July 2013 à 20:08 +0200, Yann E. MORIN a écrit :
> From: "Yann E. MORIN" <yann.morin.1998@...e.fr>
> 
> Calls to strlen are costly, so avoid calling strln as much as we can.

Typo: strln -> strlen.

> Reported-by: Jean Delvare <jdelvare@...e.de>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@...e.fr>
> Cc: Jean Delvare <jdelvare@...e.de>
> ---
>  scripts/kconfig/symbol.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
> index d550300..020a0ac 100644
> --- a/scripts/kconfig/symbol.c
> +++ b/scripts/kconfig/symbol.c
> @@ -967,7 +967,7 @@ static int sym_rel_comp( const void *sym1, const void *sym2 )
>  {
>  	struct sym_match *s1 = *(struct sym_match **)sym1;
>  	struct sym_match *s2 = *(struct sym_match **)sym2;
> -	int l1, l2;
> +	int exact1, exact2;
>  
>  	/* Exact match:
>  	 * - if matched length on symbol s1 is the length of that symbol,
> @@ -978,11 +978,11 @@ static int sym_rel_comp( const void *sym1, const void *sym2 )
>  	 * exactly; if this is the case, we can't decide which comes first,
>  	 * and we fallback to sorting alphabetically.
>  	 */
> -	l1 = s1->eo - s1->so;
> -	l2 = s2->eo - s2->so;
> -	if (l1 == strlen(s1->sym->name) && l2 != strlen(s2->sym->name))
> +	exact1 = (s1->eo - s1->so) == strlen(s1->sym->name);
> +	exact2 = (s2->eo - s2->so) == strlen(s2->sym->name);
> +	if (exact1 && !exact2)
>  		return -1;
> -	if (l1 != strlen(s1->sym->name) && l2 == strlen(s2->sym->name))
> +	if (!exact1 && exact2)
>  		return 1;
>  
>  	/* As a fallback, sort symbols alphabetically */

Looks good and tested OK.

Reviewed-by: Jean Delvare <jdelvare@...e.de>

-- 
Jean Delvare
Suse L3

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