Skip to contentSkip to conversation

arch/x86/kernel/process.c: avoid unnecessary NULL check in get_wchan

PATCH New Yafang Shao 2 participants 3 messages Nov 21, 2018 – Nov 23, 2018 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arch/x86/kernel/process.c: avoid unnecessary NULL check in get_wchan

Because the task p is always guaranteed to be non-NULL.

---
 arch/x86/kernel/process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/process.c +1 -1
index c93fcfd..3c3ee89 100644
@@ -730,7 +730,7 @@ unsigned long get_wchan(struct task_struct *p)
 	unsigned long start, bottom, top, sp, fp, ip, ret = 0;
 	int count = 0;
 
-	if (!p || p == current || p->state == TASK_RUNNING)
+	if (p == current || p->state == TASK_RUNNING)
 		return 0;
 
 	if (!try_get_task_stack(p))
Signature · 1 line
1.8.3.1
#1 lore raw

[tip:x86/cleanups] x86/process: Avoid unnecessary NULL check in get_wchan()

x86/process: Avoid unnecessary NULL check in get_wchan()
Commit-ID:  c382986fe178d02abdfcd6f4e7b9783c2922872c
Gitweb:     https://git.kernel.org/tip/c382986fe178d02abdfcd6f4e7b9783c2922872c
Author:     Yafang Shao <[email protected]>
AuthorDate: Wed, 21 Nov 2018 19:12:14 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 22 Nov 2018 10:07:21 +0100

x86/process: Avoid unnecessary NULL check in get_wchan()

Task 'p' is always guaranteed to be non-NULL, because the only call sites are in fs/proc/ which all guarantee a non-NULL task pointer.

[ mingo: Improved the changelog. ]
Cc Andy Lutomirski <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 arch/x86/kernel/process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/process.c +1 -1
index 8a33d4ad9661..b7cb5348f37f 100644
@@ -733,7 +733,7 @@ unsigned long get_wchan(struct task_struct *p)
 	unsigned long start, bottom, top, sp, fp, ip, ret = 0;
 	int count = 0;
 
-	if (!p || p == current || p->state == TASK_RUNNING)
+	if (p == current || p->state == TASK_RUNNING)
 		return 0;
 
 	if (!try_get_task_stack(p))
#2 lore raw

[tip:x86/cleanups] x86/process: Avoid unnecessary NULL check in get_wchan()

In reply to Yafang Shao
x86/process: Avoid unnecessary NULL check in get_wchan()
Commit-ID:  6e662ae7bce6db602f79e57791f5fb887fb7d371
Gitweb:     https://git.kernel.org/tip/6e662ae7bce6db602f79e57791f5fb887fb7d371
Author:     Yafang Shao <[email protected]>
AuthorDate: Wed, 21 Nov 2018 19:12:14 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 23 Nov 2018 07:58:23 +0100

x86/process: Avoid unnecessary NULL check in get_wchan()

Task 'p' is always guaranteed to be non-NULL, because the only call sites are in fs/proc/ which all guarantee a non-NULL task pointer.

[ mingo: Improved the changelog. ]
Cc Andy Lutomirski <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 arch/x86/kernel/process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/process.c +1 -1
index c93fcfdf1673..3c3ee8982577 100644
@@ -730,7 +730,7 @@ unsigned long get_wchan(struct task_struct *p)
 	unsigned long start, bottom, top, sp, fp, ip, ret = 0;
 	int count = 0;
 
-	if (!p || p == current || p->state == TASK_RUNNING)
+	if (p == current || p->state == TASK_RUNNING)
 		return 0;
 
 	if (!try_get_task_stack(p))