Skip to contentSkip to conversation

exit: silence a bogus static checker warning

PATCH Superseded Dan Carpenter 2 participants 2 messages Nov 18, 2014 Kernel janitors

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exit: silence a bogus static checker warning

Smatch complains about this:

kernel/exit.c:543 forget_original_parent()
warn: add some parenthesis here?

I don't normally advocate changing the code to make the static checker happy but these are normally precedence bugs so I think it's ok to put parenthesis so it's clear the code is deliberate.

kernel/exit.c +1 -1
index 6192422..1192d12 100644
@@ -540,7 +540,7 @@ static void forget_original_parent(struct task_struct *father)
 	list_for_each_entry(p, &father->children, sibling) {
 		for_each_thread(p, t) {
 			t->real_parent = reaper;
-			BUG_ON(!t->ptrace != (t->parent = father));
+			BUG_ON((!t->ptrace) != (t->parent = father));
 			if (likely(!t->ptrace))
 				t->parent = t->real_parent;
 			if (t->pdeath_signal)
#1 lore raw
Quoted 9 lines · Dan Carpenter

Smatch complains about this:

kernel/exit.c:543 forget_original_parent()
warn: add some parenthesis here?

I don't normally advocate changing the code to make the static checker happy but these are normally precedence bugs so I think it's ok to put parenthesis so it's clear the code is deliberate.

I still think that "if (!A = B)" doesn't look as a potential precedence bug, but I won't argue.

Andrew, this fixes exit-reparent-cleanup-the-changing-of-parent.patch
in -mm tree.

Quoted 15 lines
kernel/exit.c +1 -1
index 6192422..1192d12 100644
@@ -540,7 +540,7 @@ static void forget_original_parent(struct task_struct *father)
 	list_for_each_entry(p, &father->children, sibling) {
 		for_each_thread(p, t) {
 			t->real_parent = reaper;
-			BUG_ON(!t->ptrace != (t->parent = father));
+			BUG_ON((!t->ptrace) != (t->parent = father));
 			if (likely(!t->ptrace))
 				t->parent = t->real_parent;
 			if (t->pdeath_signal)