From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Ludovic Desroches <ludovic.desroches@microchip.com>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] mmc: atmel-mci: Reduce scope for the variable “slot” in atmci_request_end()
Date: Thu, 10 Dec 2020 16:10:35 +0100 [thread overview]
Message-ID: <20201210151035.GC1578121@piout.net> (raw)
In-Reply-To: <466b4c6d-032f-fbcc-58ac-75f6f39d734f@web.de>
Hello,
On 10/12/2020 16:01:44+0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.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@users.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
next parent reply other threads:[~2020-12-10 15:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <466b4c6d-032f-fbcc-58ac-75f6f39d734f@web.de>
2020-12-10 15:10 ` Alexandre Belloni [this message]
[not found] ` <ec71d7b8-a36b-04f5-77a8-22874ac241e1@web.de>
2020-12-10 17:07 ` [PATCH] mmc: atmel-mci: Reduce scope for the variable “slot” in atmci_request_end() Alexandre Belloni
[not found] ` <2667790c-fad2-aaa9-36e8-6be66949ac8d@web.de>
2020-12-10 18:21 ` Alexandre Belloni
[not found] ` <4c0d8efe-de25-f168-8b8d-b7f1ede6c6b1@web.de>
2020-12-11 8:03 ` Alexandre Belloni
2020-12-12 9:16 ` Joe Perches
2020-12-12 13:17 ` Alexandre Belloni
2020-12-12 18:48 ` Joe Perches
2020-12-11 8:37 ` [PATCH] " Dan Carpenter
[not found] ` <e7910b04-4c4a-567b-d87d-d12352a48cfc@web.de>
2020-12-14 7:05 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201210151035.GC1578121@piout.net \
--to=alexandre.belloni@bootlin.com \
--cc=Markus.Elfring@web.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ludovic.desroches@microchip.com \
--cc=nicolas.ferre@microchip.com \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).