[ovs-dev] [xlate v1 11/18] netdev: Support null netdev argument in netdev_ref().

Ethan Jackson ethan at nicira.com
Tue Jun 25 01:59:25 UTC 2013


This will be convenient in future patches.

Signed-off-by: Ethan Jackson <ethan at nicira.com>
---
 lib/netdev.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/netdev.c b/lib/netdev.c
index 653f5bc..d255dcc 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -277,14 +277,17 @@ netdev_open(const char *name, const char *type, struct netdev **netdevp)
     return 0;
 }
 
-/* Returns a reference to 'netdev_' for the caller to own. */
+/* Returns a reference to 'netdev_' for the caller to own. Returns null if
+ * 'netdev_' is null. */
 struct netdev *
 netdev_ref(const struct netdev *netdev_)
 {
     struct netdev *netdev = CONST_CAST(struct netdev *, netdev_);
 
-    ovs_assert(netdev->ref_cnt > 0);
-    netdev->ref_cnt++;
+    if (netdev) {
+        ovs_assert(netdev->ref_cnt > 0);
+        netdev->ref_cnt++;
+    }
     return netdev;
 }
 
-- 
1.7.9.5




More information about the dev mailing list