Skip to contentSkip to conversation

KVM: PPC: e500: Casting (void *) value returned by kmalloc is useless

PATCH In review Thomas Meyer 2 participants 4 messages Nov 8, 2011 – Nov 11, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: PPC: e500: Casting (void *) value returned by kmalloc is useless

From: Thomas Meyer <[email protected]>

Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14.

The semantic patch that makes this change is available in scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci.

More information about semantic patching is available at
http://coccinelle.lip6.fr/

---

arch/powerpc/kvm/e500_tlb.c 2011-11-08 09:18:39.955928218 +0100 renamed from arch/powerpc/kvm/e500_tlb.c 2011-11-07 19:37:27.329638682 +0100 +2 -2
diff -u -p a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c
@@ -1026,11 +1026,11 @@ int kvmppc_e500_tlb_init(struct kvmppc_v
 	if (vcpu_e500->gtlb_arch[1] == NULL)
 		goto err_out_guest0;
 
-	vcpu_e500->gtlb_priv[0] = (struct tlbe_priv *)
+	vcpu_e500->gtlb_priv[0] =
 		kzalloc(sizeof(struct tlbe_priv) * KVM_E500_TLB0_SIZE, GFP_KERNEL);
 	if (vcpu_e500->gtlb_priv[0] == NULL)
 		goto err_out_guest1;
-	vcpu_e500->gtlb_priv[1] = (struct tlbe_priv *)
+	vcpu_e500->gtlb_priv[1] =
 		kzalloc(sizeof(struct tlbe_priv) * KVM_E500_TLB1_SIZE, GFP_KERNEL);
 
 	if (vcpu_e500->gtlb_priv[1] == NULL)
#1 lore raw
Quoted 19 lines · Thomas Meyer

From: Thomas Meyer<[email protected]>

Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14.

The semantic patch that makes this change is available in scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci.

More information about semantic patching is available at
http://coccinelle.lip6.fr/

---

diff -u -p a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c

arch/powerpc/kvm/e500_tlb.c 2011-11-08 09:18:39.955928218 +0100 renamed from arch/powerpc/kvm/e500_tlb.c 2011-11-07 19:37:27.329638682 +0100 +0 -0
@@ -1026,11 +1026,11 @@ int kvmppc_e500_tlb_init(struct kvmppc_v
  	if (vcpu_e500->gtlb_arch[1] == NULL)

arch/powerpc/kvm/e500_tlb.c 2011-11-08 09:18:39.955928218 +0100 int kvmppc_e500_tlb_init(struct kvmppc_v · line 1034

Quoted 10 lines
arch/powerpc/kvm/e500_tlb.c 2011-11-08 09:18:39.955928218 +0100 renamed from arch/powerpc/kvm/e500_tlb.c 2011-11-07 19:37:27.329638682 +0100 +2 -2
  		goto err_out_guest0;
 
-	vcpu_e500->gtlb_priv[0] = (struct tlbe_priv *)
+	vcpu_e500->gtlb_priv[0] =
  		kzalloc(sizeof(struct tlbe_priv) * KVM_E500_TLB0_SIZE, GFP_KERNEL);
  	if (vcpu_e500->gtlb_priv[0] == NULL)
  		goto err_out_guest1;
-	vcpu_e500->gtlb_priv[1] = (struct tlbe_priv *)
+	vcpu_e500->gtlb_priv[1] =
  		kzalloc(sizeof(struct tlbe_priv) * KVM_E500_TLB1_SIZE, GFP_KERNEL);

Sorry, I can't seem to find that code anywhere. I suppose you're using an old git checkout?

Alex

#2 lore raw

Am Freitag, den 11.11.2011, 15:05 +0100 schrieb Alexander Graf:

Quoted 22 lines · Thomas Meyer
Quoted 21 lines

From: Thomas Meyer<[email protected]>

Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14.

The semantic patch that makes this change is available in scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci.

More information about semantic patching is available at
http://coccinelle.lip6.fr/

---

diff -u -p a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c

arch/powerpc/kvm/e500_tlb.c 2011-11-08 09:18:39.955928218 +0100 renamed from arch/powerpc/kvm/e500_tlb.c 2011-11-07 19:37:27.329638682 +0100 +0 -0
@@ -1026,11 +1026,11 @@ int kvmppc_e500_tlb_init(struct kvmppc_v
  	if (vcpu_e500->gtlb_arch[1] == NULL)
  		goto err_out_guest0;
 
Quoted 11 lines

arch/powerpc/kvm/e500_tlb.c 2011-11-08 09:18:39.955928218 +0100 int kvmppc_e500_tlb_init(struct kvmppc_v · line 1034

Quoted 8 lines
arch/powerpc/kvm/e500_tlb.c 2011-11-08 09:18:39.955928218 +0100 renamed from arch/powerpc/kvm/e500_tlb.c 2011-11-07 19:37:27.329638682 +0100 +2 -2
-	vcpu_e500->gtlb_priv[0] = (struct tlbe_priv *)
+	vcpu_e500->gtlb_priv[0] =
  		kzalloc(sizeof(struct tlbe_priv) * KVM_E500_TLB0_SIZE, GFP_KERNEL);
  	if (vcpu_e500->gtlb_priv[0] == NULL)
  		goto err_out_guest1;
-	vcpu_e500->gtlb_priv[1] = (struct tlbe_priv *)
+	vcpu_e500->gtlb_priv[1] =
  		kzalloc(sizeof(struct tlbe_priv) * KVM_E500_TLB1_SIZE, GFP_KERNEL);

Sorry, I can't seem to find that code anywhere. I suppose you're using an old git checkout?

No, I'm at 3.2-rc1:

https://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=arch/powerpc/kvm/e500_tlb.c#l1029

Quoted 4 lines

Alex

#3 lore raw
Quoted 33 lines · Thomas Meyer

Am Freitag, den 11.11.2011, 15:05 +0100 schrieb Alexander Graf:

Quoted 22 lines · Thomas Meyer
Quoted 21 lines

From: Thomas Meyer<[email protected]>

Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14.

The semantic patch that makes this change is available in scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci.

More information about semantic patching is available at
http://coccinelle.lip6.fr/

---

diff -u -p a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c

arch/powerpc/kvm/e500_tlb.c 2011-11-08 09:18:39.955928218 +0100 renamed from arch/powerpc/kvm/e500_tlb.c 2011-11-07 19:37:27.329638682 +0100 +0 -0
@@ -1026,11 +1026,11 @@ int kvmppc_e500_tlb_init(struct kvmppc_v
   	if (vcpu_e500->gtlb_arch[1] == NULL)
   		goto err_out_guest0;
 
Quoted 10 lines

arch/powerpc/kvm/e500_tlb.c 2011-11-08 09:18:39.955928218 +0100 int kvmppc_e500_tlb_init(struct kvmppc_v · line 1034

Quoted 8 lines
arch/powerpc/kvm/e500_tlb.c 2011-11-08 09:18:39.955928218 +0100 renamed from arch/powerpc/kvm/e500_tlb.c 2011-11-07 19:37:27.329638682 +0100 +2 -2
-	vcpu_e500->gtlb_priv[0] = (struct tlbe_priv *)
+	vcpu_e500->gtlb_priv[0] =
   		kzalloc(sizeof(struct tlbe_priv) * KVM_E500_TLB0_SIZE, GFP_KERNEL);
   	if (vcpu_e500->gtlb_priv[0] == NULL)
   		goto err_out_guest1;
-	vcpu_e500->gtlb_priv[1] = (struct tlbe_priv *)
+	vcpu_e500->gtlb_priv[1] =
   		kzalloc(sizeof(struct tlbe_priv) * KVM_E500_TLB1_SIZE, GFP_KERNEL);

Sorry, I can't seem to find that code anywhere. I suppose you're using an old git checkout?

Quoted 3 lines

No, I'm at 3.2-rc1:

https://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=arch/powerpc/kvm/e500_tlb.c#l1029

Ah, yes, that's old. I'm behind Avi's tree, so changes take a while to trickle through to Linus. Please check out the following (current development) tree:

git://github.com/agraf/linux-2.6.git kvm-ppc-next

Alex