Skip to contentSkip to conversation

arch: powerpc: kvm: add signed type cast for comparation

PATCH Applied Chen Gang 3 participants 5 messages Jul 22, 2013 – Aug 28, 2013

Subsystems (3)
lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH 1/1 arch: powerpc: kvm: add signed type cast for comparation

'rmls' is 'unsigned long', lpcr_rmls() will return negative number when failure occurs, so it need a type cast for comparing.

'lpid' is 'unsigned long', kvmppc_alloc_lpid() return negative number when failure occurs, so it need a type cast for comparing.

---
 arch/powerpc/kvm/book3s_hv.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_hv.c +2 -2
index 2efa9dd..7629cd3 100644
@@ -1809,7 +1809,7 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)
 		rma_size <<= PAGE_SHIFT;
 		rmls = lpcr_rmls(rma_size);
 		err = -EINVAL;
-		if (rmls < 0) {
+		if ((long)rmls < 0) {
 			pr_err("KVM: Can't use RMA of 0x%lx bytes\n", rma_size);
 			goto out_srcu;
 		}
@@ -1874,7 +1874,7 @@ int kvmppc_core_init_vm(struct kvm *kvm)
 	/* Allocate the guest's logical partition ID */
 
 	lpid = kvmppc_alloc_lpid();
-	if (lpid < 0)
+	if ((long)lpid < 0)
 		return -ENOMEM;
 	kvm->arch.lpid = lpid;
 
Signature · 1 line
1.7.7.6
author
#1 lore raw

Hello Maintainers:

Please help check this patch whether OK or not, when you have time.

Thanks.

Quoted 35 lines · Chen Gang

'rmls' is 'unsigned long', lpcr_rmls() will return negative number when failure occurs, so it need a type cast for comparing.

'lpid' is 'unsigned long', kvmppc_alloc_lpid() return negative number when failure occurs, so it need a type cast for comparing.

---
 arch/powerpc/kvm/book3s_hv.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_hv.c +2 -2
index 2efa9dd..7629cd3 100644
@@ -1809,7 +1809,7 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)
 		rma_size <<= PAGE_SHIFT;
 		rmls = lpcr_rmls(rma_size);
 		err = -EINVAL;
-		if (rmls < 0) {
+		if ((long)rmls < 0) {
 			pr_err("KVM: Can't use RMA of 0x%lx bytes\n", rma_size);
 			goto out_srcu;
 		}
@@ -1874,7 +1874,7 @@ int kvmppc_core_init_vm(struct kvm *kvm)
 	/* Allocate the guest's logical partition ID */
 
 	lpid = kvmppc_alloc_lpid();
-	if (lpid < 0)
+	if ((long)lpid < 0)
 		return -ENOMEM;
 	kvm->arch.lpid = lpid;
 
Signature · 1 line
Chen Gang
author
#3 lore raw
Quoted 4 lines · Paul Mackerras
Quoted 3 lines · Chen Gang
Quoted 3 lines

'rmls' is 'unsigned long', lpcr_rmls() will return negative number when failure occurs, so it need a type cast for comparing.

Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

'lpid' is 'unsigned long', kvmppc_alloc_lpid() return negative number when failure occurs, so it need a type cast for comparing.

Looks right, thanks.

Thank you very much.

Signature · 1 line
Chen Gang
#4 lore raw
Quoted 9 lines · Chen Gang
Quoted 8 lines · Paul Mackerras
Quoted 7 lines · Chen Gang
Quoted 7 lines

'rmls' is 'unsigned long', lpcr_rmls() will return negative number when failure occurs, so it need a type cast for comparing.

'lpid' is 'unsigned long', kvmppc_alloc_lpid() return negative number when failure occurs, so it need a type cast for comparing.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line

Looks right, thanks.

Thank you very much.

Thanks, applied to kvm-ppc-queue.

Alex