[patch 2/2] x86/vdso: Prevent empty switch case warning

Thomas Gleixner posted 2 patches 3 weeks, 3 days ago
[patch 2/2] x86/vdso: Prevent empty switch case warning
Posted by Thomas Gleixner 3 weeks, 3 days ago
Sparse complains rightfully when CONFIG_PARAVIRT_CLOCK and
CONFIG_HYPERV_TIMER are both not set:

  arch/x86/entry/vdso/vma.c:94:9: warning: switch with no cases

Add a default case to fix that.

Signed-off-by: Thomas Gleixner <tglx@kernel.org>
---
 arch/x86/entry/vdso/vma.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -114,6 +114,8 @@ static vm_fault_t vvar_vclock_fault(cons
 		break;
 	}
 #endif /* CONFIG_HYPERV_TIMER */
+	default:
+		break;
 	}
 
 	return VM_FAULT_SIGBUS;
Re: [patch 2/2] x86/vdso: Prevent empty switch case warning
Posted by Thomas Weißschuh 3 weeks, 1 day ago
Hi,

On Sat, Jan 17, 2026 at 10:58:27PM +0100, Thomas Gleixner wrote:
> Sparse complains rightfully when CONFIG_PARAVIRT_CLOCK and
> CONFIG_HYPERV_TIMER are both not set:
> 
>   arch/x86/entry/vdso/vma.c:94:9: warning: switch with no cases
> 
> Add a default case to fix that.
> 
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> ---
>  arch/x86/entry/vdso/vma.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> --- a/arch/x86/entry/vdso/vma.c
> +++ b/arch/x86/entry/vdso/vma.c
> @@ -114,6 +114,8 @@ static vm_fault_t vvar_vclock_fault(cons
>  		break;
>  	}
>  #endif /* CONFIG_HYPERV_TIMER */
> +	default:
> +		break;

This makes the code uglier only to pacify sparse.
It turns out all the necessary stub functions are in place to just
delete the ifdefs altogether. Maybe replace them with IS_ENABLED()
to make it clearer to reader what is going on.

>  	}
>  
>  	return VM_FAULT_SIGBUS;
>