linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] x86: KVM: Fix warnings by returning bool
@ 2013-01-27 16:40 Emil Goode
  2013-01-27 16:40 ` [PATCH 2/3] x86: KVM: Simplify function kvm_detect Emil Goode
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Emil Goode @ 2013-01-27 16:40 UTC (permalink / raw)
  To: mtosatti, gleb, tglx, mingo, hpa, avi, mst, perex, tiwai,
	crimsun, wfp5p, peter.senna
  Cc: x86, kvm, alsa-devel, linux-kernel, kernel-janitors, Emil Goode

The function pointer x2apic_available in struct hypervisor_x86 is
supposed to point to functions that return bool. This patch changes
the return type of the kvm_para_available function to bool.

Sparse warnings:

arch/x86/kernel/kvm.c:508:35: warning:
	incorrect type in initializer (different signedness)
	arch/x86/kernel/kvm.c:508:35:
	expected bool ( *x2apic_available )( ... )
	arch/x86/kernel/kvm.c:508:35:
	got int ( static inline [toplevel] *<noident> )( ... )

arch/x86/kernel/kvm.c:508:2: warning:
	initialization from incompatible pointer type [enabled by default]

arch/x86/kernel/kvm.c:508:2: warning:
	(near initialization for ‘x86_hyper_kvm.x2apic_available’)
	[enabled by default]

Signed-off-by: Emil Goode <emilgoode@gmail.com>
---
 arch/x86/include/asm/kvm_para.h |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h
index 0be7039..695399f 100644
--- a/arch/x86/include/asm/kvm_para.h
+++ b/arch/x86/include/asm/kvm_para.h
@@ -85,13 +85,13 @@ static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
 	return ret;
 }
 
-static inline int kvm_para_available(void)
+static inline bool kvm_para_available(void)
 {
 	unsigned int eax, ebx, ecx, edx;
 	char signature[13];
 
 	if (boot_cpu_data.cpuid_level < 0)
-		return 0;	/* So we don't blow up on old processors */
+		return false;	/* So we don't blow up on old processors */
 
 	if (cpu_has_hypervisor) {
 		cpuid(KVM_CPUID_SIGNATURE, &eax, &ebx, &ecx, &edx);
@@ -101,10 +101,10 @@ static inline int kvm_para_available(void)
 		signature[12] = 0;
 
 		if (strcmp(signature, "KVMKVMKVM") == 0)
-			return 1;
+			return true;
 	}
 
-	return 0;
+	return false;
 }
 
 static inline unsigned int kvm_arch_para_features(void)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] x86: KVM: Simplify function kvm_detect
  2013-01-27 16:40 [PATCH 1/3] x86: KVM: Fix warnings by returning bool Emil Goode
@ 2013-01-27 16:40 ` Emil Goode
  2013-01-27 16:40 ` [PATCH 3/3] ALSA: intel8x0: Check return value before assigning Emil Goode
  2013-01-29 16:36 ` [PATCH 1/3] x86: KVM: Fix warnings by returning bool Gleb Natapov
  2 siblings, 0 replies; 6+ messages in thread
From: Emil Goode @ 2013-01-27 16:40 UTC (permalink / raw)
  To: mtosatti, gleb, tglx, mingo, hpa, avi, mst, perex, tiwai,
	crimsun, wfp5p, peter.senna
  Cc: x86, kvm, alsa-devel, linux-kernel, kernel-janitors, Emil Goode

The first patch in this series changed the kvm_para_available
function to return bool. We can now simplify the kvm_detect function
by directly returning the return value of kvm_para_available.

Signed-off-by: Emil Goode <emilgoode@gmail.com>
---
 arch/x86/kernel/kvm.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 2b44ea5..3644908 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -497,9 +497,7 @@ void __init kvm_guest_init(void)
 
 static bool __init kvm_detect(void)
 {
-	if (!kvm_para_available())
-		return false;
-	return true;
+	return kvm_para_available();
 }
 
 const struct hypervisor_x86 x86_hyper_kvm __refconst = {
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] ALSA: intel8x0: Check return value before assigning
  2013-01-27 16:40 [PATCH 1/3] x86: KVM: Fix warnings by returning bool Emil Goode
  2013-01-27 16:40 ` [PATCH 2/3] x86: KVM: Simplify function kvm_detect Emil Goode
@ 2013-01-27 16:40 ` Emil Goode
  2013-01-27 16:40   ` H. Peter Anvin
  2013-01-28  8:47   ` Takashi Iwai
  2013-01-29 16:36 ` [PATCH 1/3] x86: KVM: Fix warnings by returning bool Gleb Natapov
  2 siblings, 2 replies; 6+ messages in thread
From: Emil Goode @ 2013-01-27 16:40 UTC (permalink / raw)
  To: mtosatti, gleb, tglx, mingo, hpa, avi, mst, perex, tiwai,
	crimsun, wfp5p, peter.senna
  Cc: x86, kvm, alsa-devel, linux-kernel, kernel-janitors, Emil Goode

The first patch in this series changes the return type of function
kvm_para_available to bool. In the function snd_intel8x0_inside_vm
we now need to check it's return value before assigning a value to
the result variable.

Signed-off-by: Emil Goode <emilgoode@gmail.com>
---
 sound/pci/intel8x0.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 3b9be75..fa9337e 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -2982,7 +2982,7 @@ static int snd_intel8x0_inside_vm(struct pci_dev *pci)
 	}
 
 	/* detect KVM and Parallels virtual environments */
-	result = kvm_para_available();
+	result = kvm_para_available() ? 1 : 0;
 #ifdef X86_FEATURE_HYPERVISOR
 	result = result || boot_cpu_has(X86_FEATURE_HYPERVISOR);
 #endif
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] ALSA: intel8x0: Check return value before assigning
  2013-01-27 16:40 ` [PATCH 3/3] ALSA: intel8x0: Check return value before assigning Emil Goode
@ 2013-01-27 16:40   ` H. Peter Anvin
  2013-01-28  8:47   ` Takashi Iwai
  1 sibling, 0 replies; 6+ messages in thread
From: H. Peter Anvin @ 2013-01-27 16:40 UTC (permalink / raw)
  To: Emil Goode, mtosatti, gleb, tglx, mingo, avi, mst, perex, tiwai,
	crimsun, wfp5p, peter.senna
  Cc: x86, kvm, alsa-devel, linux-kernel, kernel-janitors

Wtf?
 
This patch seems semibogus at best and the description is even more ridiculous...

Emil Goode <emilgoode@gmail.com> wrote:

>The first patch in this series changes the return type of function
>kvm_para_available to bool. In the function snd_intel8x0_inside_vm
>we now need to check it's return value before assigning a value to
>the result variable.
>
>Signed-off-by: Emil Goode <emilgoode@gmail.com>
>---
> sound/pci/intel8x0.c |    2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
>index 3b9be75..fa9337e 100644
>--- a/sound/pci/intel8x0.c
>+++ b/sound/pci/intel8x0.c
>@@ -2982,7 +2982,7 @@ static int snd_intel8x0_inside_vm(struct pci_dev
>*pci)
> 	}
> 
> 	/* detect KVM and Parallels virtual environments */
>-	result = kvm_para_available();
>+	result = kvm_para_available() ? 1 : 0;
> #ifdef X86_FEATURE_HYPERVISOR
> 	result = result || boot_cpu_has(X86_FEATURE_HYPERVISOR);
> #endif

-- 
Sent from my mobile phone. Please excuse brevity and lack of formatting.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] ALSA: intel8x0: Check return value before assigning
  2013-01-27 16:40 ` [PATCH 3/3] ALSA: intel8x0: Check return value before assigning Emil Goode
  2013-01-27 16:40   ` H. Peter Anvin
@ 2013-01-28  8:47   ` Takashi Iwai
  1 sibling, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2013-01-28  8:47 UTC (permalink / raw)
  To: Emil Goode
  Cc: mtosatti, gleb, tglx, mingo, hpa, avi, mst, perex, crimsun,
	wfp5p, peter.senna, x86, kvm, alsa-devel, linux-kernel,
	kernel-janitors

At Sun, 27 Jan 2013 17:40:02 +0100,
Emil Goode wrote:
> 
> The first patch in this series changes the return type of function
> kvm_para_available to bool. In the function snd_intel8x0_inside_vm
> we now need to check it's return value before assigning a value to
> the result variable.
> 
> Signed-off-by: Emil Goode <emilgoode@gmail.com>
> ---
>  sound/pci/intel8x0.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
> index 3b9be75..fa9337e 100644
> --- a/sound/pci/intel8x0.c
> +++ b/sound/pci/intel8x0.c
> @@ -2982,7 +2982,7 @@ static int snd_intel8x0_inside_vm(struct pci_dev *pci)
>  	}
>  
>  	/* detect KVM and Parallels virtual environments */
> -	result = kvm_para_available();
> +	result = kvm_para_available() ? 1 : 0;

This is superfluous.  The conversion from bool to int works implicitly
like that.


Takashi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] x86: KVM: Fix warnings by returning bool
  2013-01-27 16:40 [PATCH 1/3] x86: KVM: Fix warnings by returning bool Emil Goode
  2013-01-27 16:40 ` [PATCH 2/3] x86: KVM: Simplify function kvm_detect Emil Goode
  2013-01-27 16:40 ` [PATCH 3/3] ALSA: intel8x0: Check return value before assigning Emil Goode
@ 2013-01-29 16:36 ` Gleb Natapov
  2 siblings, 0 replies; 6+ messages in thread
From: Gleb Natapov @ 2013-01-29 16:36 UTC (permalink / raw)
  To: Emil Goode
  Cc: mtosatti, tglx, mingo, hpa, avi, mst, perex, tiwai, crimsun,
	wfp5p, peter.senna, x86, kvm, alsa-devel, linux-kernel,
	kernel-janitors

On Sun, Jan 27, 2013 at 05:40:00PM +0100, Emil Goode wrote:
> The function pointer x2apic_available in struct hypervisor_x86 is
> supposed to point to functions that return bool. This patch changes
> the return type of the kvm_para_available function to bool.
> 
> Sparse warnings:
> 
> arch/x86/kernel/kvm.c:508:35: warning:
> 	incorrect type in initializer (different signedness)
> 	arch/x86/kernel/kvm.c:508:35:
> 	expected bool ( *x2apic_available )( ... )
> 	arch/x86/kernel/kvm.c:508:35:
> 	got int ( static inline [toplevel] *<noident> )( ... )
> 
> arch/x86/kernel/kvm.c:508:2: warning:
> 	initialization from incompatible pointer type [enabled by default]
> 
> arch/x86/kernel/kvm.c:508:2: warning:
> 	(near initialization for ‘x86_hyper_kvm.x2apic_available’)
> 	[enabled by default]
> 
The breakage was in tip x86/apic tree only and it was fixed by
3b4a505821 there.

> Signed-off-by: Emil Goode <emilgoode@gmail.com>
> ---
>  arch/x86/include/asm/kvm_para.h |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h
> index 0be7039..695399f 100644
> --- a/arch/x86/include/asm/kvm_para.h
> +++ b/arch/x86/include/asm/kvm_para.h
> @@ -85,13 +85,13 @@ static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
>  	return ret;
>  }
>  
> -static inline int kvm_para_available(void)
> +static inline bool kvm_para_available(void)
>  {
>  	unsigned int eax, ebx, ecx, edx;
>  	char signature[13];
>  
>  	if (boot_cpu_data.cpuid_level < 0)
> -		return 0;	/* So we don't blow up on old processors */
> +		return false;	/* So we don't blow up on old processors */
>  
>  	if (cpu_has_hypervisor) {
>  		cpuid(KVM_CPUID_SIGNATURE, &eax, &ebx, &ecx, &edx);
> @@ -101,10 +101,10 @@ static inline int kvm_para_available(void)
>  		signature[12] = 0;
>  
>  		if (strcmp(signature, "KVMKVMKVM") == 0)
> -			return 1;
> +			return true;
>  	}
>  
> -	return 0;
> +	return false;
>  }
>  
>  static inline unsigned int kvm_arch_para_features(void)
> -- 
> 1.7.10.4

--
			Gleb.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-01-29 16:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-27 16:40 [PATCH 1/3] x86: KVM: Fix warnings by returning bool Emil Goode
2013-01-27 16:40 ` [PATCH 2/3] x86: KVM: Simplify function kvm_detect Emil Goode
2013-01-27 16:40 ` [PATCH 3/3] ALSA: intel8x0: Check return value before assigning Emil Goode
2013-01-27 16:40   ` H. Peter Anvin
2013-01-28  8:47   ` Takashi Iwai
2013-01-29 16:36 ` [PATCH 1/3] x86: KVM: Fix warnings by returning bool Gleb Natapov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).