[PATCH] cxl: Reduce scope for the variable “mm” in cxllib_get_PE_attributes()

Subsystems: char and misc drivers, the rest

STALE2024d LANDED

Landed in mainline as 245a389c6ded on 2021-01-31.

4 messages, 3 authors, 2021-02-03 · open the first message on its own page

[PATCH] cxl: Reduce scope for the variable “mm” in cxllib_get_PE_attributes()

From: Markus Elfring <hidden>
Date: 2020-12-10 15:47:03

From: Markus Elfring <redacted>
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 <redacted>
---
 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

Re: [PATCH] cxl: Reduce scope for the variable “mm” in cxllib_get_PE_attributes()

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: 2020-12-10 14:51:08

On Thu, Dec 10, 2020 at 03:35:38PM +0100, Markus Elfring wrote:
From: Markus Elfring <redacted>
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.
You did nothing here except add a checkpatch warning :(

dropped.

greg k-h

Re: [PATCH] cxl: Reduce scope for the variable “mm” in cxllib_get_PE_attributes()

From: Markus Elfring <hidden>
Date: 2020-12-10 16:10:38

quoted
A local variable was used only within an if branch.
Thus move the definition for the variable “mm” into the corresponding
code block.
You did nothing here except add a checkpatch warning :(
elfring@Sonne:~/Projekte/Linux/next-patched> scripts/checkpatch.pl /home/elfring/Projekte/Bau/Linux/scripts/Coccinelle/tuning1/next/20201204/Flicken/0001-cxl-Reduce-scope-for-the-variable-mm-in-cxllib_get_P.patch
total: 0 errors, 0 warnings, 16 lines checked

Regards,
Markus

Re: [PATCH] cxl: Reduce scope for the variable “mm” in cxllib_get_PE_attributes()

From: Michael Ellerman <hidden>
Date: 2021-02-03 12:40:32

On Thu, 10 Dec 2020 15:35:38 +0100, Markus Elfring wrote:
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.
Applied to powerpc/next.

[1/1] cxl: Reduce scope for the variable ���mm��� in cxllib_get_PE_attributes()
      https://git.kernel.org/powerpc/c/245a389c6ded15a7d308dbe988aec8a96e8aa8cf

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help