Messages in this thread | | | Date | Thu, 10 Dec 2020 16:10:35 +0100 | From | Alexandre Belloni <> | Subject | Re: [PATCH] mmc: atmel-mci: Redu ce 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@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
| |