From: Ethan Jackson Date: Tue, 25 Jun 2013 00:23:15 +0000 (-0700) Subject: netdev: Support null netdev argument in netdev_ref(). X-Git-Tag: sliver-openvswitch-1.10.90-3~6^2~29 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=e20ae8113625b15f9231f74102d7b7d1eea6a4f6;p=sliver-openvswitch.git netdev: Support null netdev argument in netdev_ref(). This will be convenient in future patches. Signed-off-by: Ethan Jackson Acked-by: Ben Pfaff --- diff --git a/lib/netdev.c b/lib/netdev.c index 653f5bca7..d255dcc72 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; }