All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: linuxppc-dev@lists.ozlabs.org,
	Andrew Donnellan <ajd@linux.ibm.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Frederic Barrat <fbarrat@linux.ibm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: kernel-janitors@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] cxl: Reduce scope for the variable “mm” in cxllib_get_PE_attributes()
Date: Thu, 10 Dec 2020 15:35:38 +0100	[thread overview]
Message-ID: <5cee2b25-71e0-15aa-fba6-12211b8308aa@web.de> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 10 Dec 2020 14:14:07 +0100

A local variable was used only within an if branch.
Thus move the definition for the variable “mm” into the corresponding
code block.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/misc/cxl/cxllib.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/misc/cxl/cxllib.c b/drivers/misc/cxl/cxllib.c
index 2a1783f32254..53b919856426 100644
--- a/drivers/misc/cxl/cxllib.c
+++ b/drivers/misc/cxl/cxllib.c
@@ -170,8 +170,6 @@ int cxllib_get_PE_attributes(struct task_struct *task,
 			     unsigned long translation_mode,
 			     struct cxllib_pe_attributes *attr)
 {
-	struct mm_struct *mm = NULL;
-
 	if (translation_mode != CXL_TRANSLATED_MODE &&
 		translation_mode != CXL_REAL_MODE)
 		return -EINVAL;
@@ -182,7 +180,7 @@ int cxllib_get_PE_attributes(struct task_struct *task,
 				true);
 	attr->lpid = mfspr(SPRN_LPID);
 	if (task) {
-		mm = get_task_mm(task);
+		struct mm_struct *mm = get_task_mm(task);
 		if (mm == NULL)
 			return -EINVAL;
 		/*
--
2.29.2


             reply	other threads:[~2020-12-10 15:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-10 14:35 Markus Elfring [this message]
2020-12-10 14:47 ` [PATCH] cxl: Reduce scope for the variable “mm” in cxllib_get_PE_attributes() Greg Kroah-Hartman
2020-12-10 14:47   ` Greg Kroah-Hartman
2020-12-10 14:47   ` [PATCH] cxl: Reduce scope for the variable “mm” in cxllib_ Greg Kroah-Hartman
2020-12-10 16:04   ` [PATCH] cxl: Reduce scope for the variable “mm” in cxllib_get_PE_attributes() Markus Elfring
2020-12-10 18:01     ` Christophe JAILLET
2020-12-10 18:01       ` [PATCH] cxl: Reduce scope for the variable =?UTF-8?B?4oCcbW3igJ0gaW4gY3hsbG Christophe JAILLET
2021-02-03 11:40 ` [PATCH] cxl: Reduce scope for the variable “mm” in cxllib_get_PE_attributes() Michael Ellerman

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=5cee2b25-71e0-15aa-fba6-12211b8308aa@web.de \
    --to=markus.elfring@web.de \
    --cc=ajd@linux.ibm.com \
    --cc=arnd@arndb.de \
    --cc=fbarrat@linux.ibm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.