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-next>] [day] [month] [year] [list]
Date:   Thu, 10 Dec 2020 16:10:35 +0100
From:   Alexandre Belloni <alexandre.belloni@...tlin.com>
To:     Markus Elfring <Markus.Elfring@....de>
Cc:     linux-mmc@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        Ludovic Desroches <ludovic.desroches@...rochip.com>,
        Nicolas Ferre <nicolas.ferre@...rochip.com>,
        Ulf Hansson <ulf.hansson@...aro.org>,
        LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] mmc: atmel-mci: Reduce scope for the variable “slot” in
 atmci_request_end()

Hello,

On 10/12/2020 16:01:44+0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@...rs.sourceforge.net>
> Date: Thu, 10 Dec 2020 15:56:13 +0100
> 
> A local variable was used only within an if branch.
> Thus move the definition for the variable “slot” into the corresponding
> code block.
> 

What is the improvement here?

This makes the code harder to read.

> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
> ---
>  drivers/mmc/host/atmel-mci.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 444bd3a0a922..6a0d999ee82e 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -1558,7 +1558,6 @@ static void atmci_request_end(struct atmel_mci *host, struct mmc_request *mrq)
>  	__releases(&host->lock)
>  	__acquires(&host->lock)
>  {
> -	struct atmel_mci_slot	*slot = NULL;
>  	struct mmc_host		*prev_mmc = host->cur_slot->mmc;
> 
>  	WARN_ON(host->cmd || host->data);
> @@ -1579,8 +1578,9 @@ static void atmci_request_end(struct atmel_mci *host, struct mmc_request *mrq)
>  	host->cur_slot->mrq = NULL;
>  	host->mrq = NULL;
>  	if (!list_empty(&host->queue)) {
> -		slot = list_entry(host->queue.next,
> -				struct atmel_mci_slot, queue_node);
> +		struct atmel_mci_slot *slot = list_entry(host->queue.next,
> +							 struct atmel_mci_slot,
> +							 queue_node);
>  		list_del(&slot->queue_node);
>  		dev_vdbg(&host->pdev->dev, "list not empty: %s is next\n",
>  				mmc_hostname(slot->mmc));
> --
> 2.29.2
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ