Skip to contentSkip to conversation

netfilter: use PTR_RET

PATCH Applied Fengguang Wu 2 participants 4 messages Oct 29, 2012

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

PATCH 1/1 netfilter: use PTR_RET

Use PTR_RET rather than if(IS_ERR(...)) + PTR_ERR

Generated by: coccinelle/api/ptr_ret.cocci

---

 net/ipv4/netfilter/iptable_nat.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
net/ipv4/netfilter/iptable_nat.c +1 -3
@@ -274,9 +274,7 @@ static int __net_init iptable_nat_net_in
 		return -ENOMEM;
 	net->ipv4.nat_table = ipt_register_table(net, &nf_nat_ipv4_table, repl);
 	kfree(repl);
-	if (IS_ERR(net->ipv4.nat_table))
-		return PTR_ERR(net->ipv4.nat_table);
-	return 0;
+	return PTR_RET(net->ipv4.nat_table);
 }
 
 static void __net_exit iptable_nat_net_exit(struct net *net)
#1 lore raw

PATCH 1/1 netfilter: ipv6: use PTR_RET

Use PTR_RET rather than if(IS_ERR(...)) + PTR_ERR

Generated by: coccinelle/api/ptr_ret.cocci

---
 net/ipv6/netfilter/ip6table_nat.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
net/ipv6/netfilter/ip6table_nat.c +1 -3
@@ -275,9 +275,7 @@ static int __net_init ip6table_nat_net_i
 		return -ENOMEM;
 	net->ipv6.ip6table_nat = ip6t_register_table(net, &nf_nat_ipv6_table, repl);
 	kfree(repl);
-	if (IS_ERR(net->ipv6.ip6table_nat))
-		return PTR_ERR(net->ipv6.ip6table_nat);
-	return 0;
+	return PTR_RET(net->ipv6.ip6table_nat);
 }
 
 static void __net_exit ip6table_nat_net_exit(struct net *net)
maintainer Applied
#2 lore raw
In reply to Fengguang Wu
Quoted 3 lines · Fengguang Wu

Use PTR_RET rather than if(IS_ERR(...)) + PTR_ERR

Generated by: coccinelle/api/ptr_ret.cocci

Applied, thanks.

I have collapsed this patch and the one for ipv6/iptable_nat.c. They are pretty small and description is the same.

#3 lore raw
Quoted 9 lines · Pablo Neira Ayuso
Quoted 3 lines · Fengguang Wu

Use PTR_RET rather than if(IS_ERR(...)) + PTR_ERR

Generated by: coccinelle/api/ptr_ret.cocci

Applied, thanks.

I have collapsed this patch and the one for ipv6/iptable_nat.c. They are pretty small and description is the same.

That would be good, thanks!

Thanks,
Fengguang