diff mbox series

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

Message ID 5cee2b25-71e0-15aa-fba6-12211b8308aa@web.de (mailing list archive)
State Accepted
Headers show
Series cxl: Reduce scope for the variable “mm” in cxllib_get_PE_attributes() | expand

Commit Message

Markus Elfring Dec. 10, 2020, 2:35 p.m. UTC
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(-)

--
2.29.2

Comments

Markus Elfring Dec. 10, 2020, 4:04 p.m. UTC | #1
>> 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
Michael Ellerman Feb. 3, 2021, 11:40 a.m. UTC | #2
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
diff mbox series

Patch

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;
 		/*