diff mbox

[ovs-dev,17/24] datapath: use PTR_ERR_OR_ZERO

Message ID 1468387602-61955-8-git-send-email-pshelar@ovn.org
State Accepted
Headers show

Commit Message

Pravin Shelar July 13, 2016, 5:26 a.m. UTC
Upstream commit:
    commit f35423c137b0e64155f52c166db1d13834a551f2
    Author: Fabian Frederick <fabf@skynet.be>

    openvswitch: use PTR_ERR_OR_ZERO

    Signed-off-by: Fabian Frederick <fabf@skynet.be>
    Acked-by: Pravin B Shelar <pshelar@ovn.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
---
 acinclude.m4                              | 1 +
 datapath/flow_netlink.c                   | 4 +---
 datapath/linux/compat/include/linux/err.h | 9 +++++++++
 3 files changed, 11 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/acinclude.m4 b/acinclude.m4
index ef796d3..083ef77 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -389,6 +389,7 @@  AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
 
   OVS_GREP_IFELSE([$KSRC/include/linux/err.h], [ERR_CAST])
   OVS_GREP_IFELSE([$KSRC/include/linux/err.h], [IS_ERR_OR_NULL])
+  OVS_GREP_IFELSE([$KSRC/include/linux/err.h], [PTR_ERR_OR_ZERO])
 
   OVS_GREP_IFELSE([$KSRC/include/linux/etherdevice.h], [eth_hw_addr_random])
   OVS_GREP_IFELSE([$KSRC/include/linux/etherdevice.h], [ether_addr_copy])
diff --git a/datapath/flow_netlink.c b/datapath/flow_netlink.c
index c1287f8..fc0ee10 100644
--- a/datapath/flow_netlink.c
+++ b/datapath/flow_netlink.c
@@ -1801,10 +1801,8 @@  int ovs_nla_add_action(struct sw_flow_actions **sfa, int attrtype, void *data,
 	struct nlattr *a;
 
 	a = __add_action(sfa, attrtype, data, len, log);
-	if (IS_ERR(a))
-		return PTR_ERR(a);
 
-	return 0;
+	return PTR_ERR_OR_ZERO(a);
 }
 
 static inline int add_nested_action_start(struct sw_flow_actions **sfa,
diff --git a/datapath/linux/compat/include/linux/err.h b/datapath/linux/compat/include/linux/err.h
index 4a4ce7e..321386c 100644
--- a/datapath/linux/compat/include/linux/err.h
+++ b/datapath/linux/compat/include/linux/err.h
@@ -25,4 +25,13 @@  static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
 }
 #endif
 
+#ifndef HAVE_PTR_ERR_OR_ZERO
+static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
+{
+	if (IS_ERR(ptr))
+		return PTR_ERR(ptr);
+	else
+		return 0;
+}
+#endif
 #endif