Skip to contentSkip to conversation

block: drop needless assignment in set_task_ioprio()

PATCH Applied Lukas Bulwahn 3 participants 3 messages Dec 23, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 block: drop needless assignment in set_task_ioprio()

Commit 5fc11eebb4a9 ("block: open code create_task_io_context in set_task_ioprio") introduces a needless assignment
'ioc = task->io_context', as the local variable ioc is not further used before returning.

Even after the further fix, commit a957b61254a7 ("block: fix error in handling dead task for ioprio setting"), the assignment still remains needless.

Drop this needless assignment in set_task_ioprio().

This code smell was identified with 'make clang-analyzer'.

Fixes 5fc11eebb4a9 ("block: open code create_task_io_context in set_task_ioprio")
---
 block/blk-ioc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
block/blk-ioc.c +2 -4
index 71c3a933cf16..11f49f78db32 100644
@@ -284,12 +284,10 @@ int set_task_ioprio(struct task_struct *task, int ioprio)
 			kmem_cache_free(iocontext_cachep, ioc);
 			goto out;
 		}
-		if (task->io_context) {
+		if (task->io_context)
 			kmem_cache_free(iocontext_cachep, ioc);
-			ioc = task->io_context;
-		} else {
+		else
 			task->io_context = ioc;
-		}
 	}
 	task->io_context->ioprio = ioprio;
 out:
Signature · 1 line
2.17.1
maintainer Applied
#2 lore raw
In reply to Lukas Bulwahn
Quoted 10 lines · Lukas Bulwahn

Commit 5fc11eebb4a9 ("block: open code create_task_io_context in set_task_ioprio") introduces a needless assignment
'ioc = task->io_context', as the local variable ioc is not further used before returning.

Even after the further fix, commit a957b61254a7 ("block: fix error in handling dead task for ioprio setting"), the assignment still remains needless.

[...]

Applied, thanks!

[1/1] block: drop needless assignment in set_task_ioprio()

      commit: 669a064625fa3a06ddf8a4ac1f35b7436b99f133

Best regards,

Signature · 1 line
Jens Axboe