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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2e9385a0-56ea-0a2f-6389-7530c34a5364@codeaurora.org>
Date:   Tue, 13 Oct 2020 18:39:54 -0700
From:   Mike Tipton <mdtipton@...eaurora.org>
To:     Georgi Djakov <georgi.djakov@...aro.org>, linux-pm@...r.kernel.org
Cc:     okukatla@...eaurora.org, sibis@...eaurora.org,
        bjorn.andersson@...aro.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] interconnect: qcom: Simplify the vcd compare function

On 10/13/2020 10:19 AM, Georgi Djakov wrote:
> Let's simplify the cmp_vcd() function and replace the conditionals
> with just a single statement, which also improves readability.
> 
> Signed-off-by: Georgi Djakov <georgi.djakov@...aro.org>
> ---
>   drivers/interconnect/qcom/bcm-voter.c | 15 ++++-----------
>   1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/interconnect/qcom/bcm-voter.c b/drivers/interconnect/qcom/bcm-voter.c
> index 887d13721e52..1cc565bce2f4 100644
> --- a/drivers/interconnect/qcom/bcm-voter.c
> +++ b/drivers/interconnect/qcom/bcm-voter.c
> @@ -41,17 +41,10 @@ struct bcm_voter {
>   
>   static int cmp_vcd(void *priv, struct list_head *a, struct list_head *b)
>   {
> -	const struct qcom_icc_bcm *bcm_a =
> -			list_entry(a, struct qcom_icc_bcm, list);
> -	const struct qcom_icc_bcm *bcm_b =
> -			list_entry(b, struct qcom_icc_bcm, list);
> -
> -	if (bcm_a->aux_data.vcd < bcm_b->aux_data.vcd)
> -		return -1;
> -	else if (bcm_a->aux_data.vcd == bcm_b->aux_data.vcd)
> -		return 0;
> -	else
> -		return 1;
> +	const struct qcom_icc_bcm *bcm_a = list_entry(a, struct qcom_icc_bcm, list);
> +	const struct qcom_icc_bcm *bcm_b = list_entry(b, struct qcom_icc_bcm, list);
> +
> +	return bcm_a->aux_data.vcd - bcm_b->aux_data.vcd;
>   }
>   
>   static u64 bcm_div(u64 num, u32 base)
> 

Reviewed-by: Mike Tipton <mdtipton@...eaurora.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ