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] [day] [month] [year] [list]
Message-Id: <201308221101.10749.heiko@sntech.de>
Date:	Thu, 22 Aug 2013 11:01:09 +0200
From:	Heiko Stübner <heiko@...ech.de>
To:	Axel Lin <axel.lin@...ics.com>
Cc:	Linus Walleij <linus.walleij@...aro.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] pinctrl: rockchip: Simplify for loop iteration

Am Mittwoch, 21. August 2013, 04:28:50 schrieb Axel Lin:
> Just return once a match found makes the code simpler and shorter.
> 
> Signed-off-by: Axel Lin <axel.lin@...ics.com>

as I'm a bit late for an Ack it seems, I can only offer a thanks for making 
this nicer :-)


Heiko


> ---
>  drivers/pinctrl/pinctrl-rockchip.c | 21 ++++++---------------
>  1 file changed, 6 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-rockchip.c
> b/drivers/pinctrl/pinctrl-rockchip.c index c22457d..64ad0c0 100644
> --- a/drivers/pinctrl/pinctrl-rockchip.c
> +++ b/drivers/pinctrl/pinctrl-rockchip.c
> @@ -167,18 +167,14 @@ static const inline struct rockchip_pin_group
> *pinctrl_name_to_group( const struct rockchip_pinctrl *info,
>  					const char *name)
>  {
> -	const struct rockchip_pin_group *grp = NULL;
>  	int i;
> 
>  	for (i = 0; i < info->ngroups; i++) {
> -		if (strcmp(info->groups[i].name, name))
> -			continue;
> -
> -		grp = &info->groups[i];
> -		break;
> +		if (!strcmp(info->groups[i].name, name))
> +			return &info->groups[i];
>  	}
> 
> -	return grp;
> +	return NULL;
>  }
> 
>  /*
> @@ -204,17 +200,12 @@ static struct rockchip_pin_bank *bank_num_to_bank(
>  	struct rockchip_pin_bank *b = info->ctrl->pin_banks;
>  	int i;
> 
> -	for (i = 0; i < info->ctrl->nr_banks; i++) {
> +	for (i = 0; i < info->ctrl->nr_banks; i++, b++) {
>  		if (b->bank_num == num)
> -			break;
> -
> -		b++;
> +			return b;
>  	}
> 
> -	if (b->bank_num != num)
> -		return ERR_PTR(-EINVAL);
> -
> -	return b;
> +	return ERR_PTR(-EINVAL);
>  }
> 
>  /*

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