Skip to contentSkip to conversation

x86: Function missing integer return value

PATCH In review Li kunyu 4 participants 5 messages May 5, 2022

Subsystems (3)
lore
Share & tools
lore

Li kunyu

author
#0 lore raw

PATCH 1/1 x86: Function missing integer return value

This function may need to return a value

---
 arch/x86/kvm/mmu/mmu.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/kvm/mmu/mmu.c +2 -0
index 64a2a7e2be90..68f33b932f94 100644
@@ -6500,6 +6500,8 @@ static int kvm_nx_lpage_recovery_worker(struct kvm *kvm, uintptr_t data)
 
 		kvm_recover_nx_lpages(kvm);
 	}
+
+	return 0;
 }
 
 int kvm_mmu_post_init_vm(struct kvm *kvm)
Signature · 1 line
2.18.2
#1 lore raw
Quoted 12 lines · Li kunyu

This function may need to return a value

---
  arch/x86/kvm/mmu/mmu.c | 2 ++
  1 file changed, 2 insertions(+)
arch/x86/kvm/mmu/mmu.c +0 -0
index 64a2a7e2be90..68f33b932f94 100644

arch/x86/kvm/mmu/mmu.c static int kvm_nx_lpage_recovery_worker(struct kvm *kvm, uintptr_t data) · line 6504

Quoted 5 lines
arch/x86/kvm/mmu/mmu.c +2 -0
@@ -6500,6 +6500,8 @@ static int kvm_nx_lpage_recovery_worker(struct kvm *kvm, uintptr_t data)
 
  		kvm_recover_nx_lpages(kvm);
  	}
+
+	return 0;

This statement is not reachable, so the patch is adding unneeded dead code only.

Juergen

#2 lore raw
Quoted 8 lines · Juergen Gross
Quoted 7 lines · Li kunyu

This function may need to return a value

---
  arch/x86/kvm/mmu/mmu.c | 2 ++

  1 file changed, 2 insertions(+)
Quoted 12 lines

arch/x86/kvm/mmu/mmu.c static int kvm_nx_lpage_recovery_worker(struct kvm *kvm, uintptr_t data) · line 6503

Quoted 9 lines
arch/x86/kvm/mmu/mmu.c +2 -0
index 64a2a7e2be90..68f33b932f94 100644
@@ -6500,6 +6500,8 @@ static int kvm_nx_lpage_recovery_worker(struct kvm *kvm, uintptr_t data)
           kvm_recover_nx_lpages(kvm);
       }
+
+    return 0;

This statement is not reachable, so the patch is adding unneeded dead code only.

Maybe some static checker isn't smart enough to figure this out.

In this case it would probably be better to also change:

Quoted 2 lines

if (kthread_should_stop())

    return 0;

into:

Quoted 2 lines

if (kthread_should_stop())

    break;

so the newly introduced code isn't dead.

Quoted 1 line

Juergen

Thanks,
Maciej

maintainer
#3 lore raw
Quoted 4 lines · Maciej S. Szmigiero
Quoted 2 lines

This statement is not reachable, so the patch is adding unneeded dead code only.

Maybe some static checker isn't smart enough to figure this out.

The static checker really should be improved. This is a while(true), not the halting problem. :)

Paolo