diff mbox

[ovs-dev,v3,08/16] lport: Tolerate null pointers in destroy functions.

Message ID 20161218081834.18541-9-blp@ovn.org
State Accepted
Headers show

Commit Message

Ben Pfaff Dec. 18, 2016, 8:18 a.m. UTC
The coding style says to do this.

The actual caller doesn't pass a null pointer.

Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 ovn/controller/lport.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Mickey Spiegel Dec. 19, 2016, 12:07 a.m. UTC | #1
On Sun, Dec 18, 2016 at 12:18 AM, Ben Pfaff <blp@ovn.org> wrote:

> The coding style says to do this.
>
> The actual caller doesn't pass a null pointer.
>
> Signed-off-by: Ben Pfaff <blp@ovn.org>


Acked-by: Mickey Spiegel <mickeys.dev@gmail.com>

---
>  ovn/controller/lport.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/ovn/controller/lport.c b/ovn/controller/lport.c
> index 3484c2c..38aca22 100644
> --- a/ovn/controller/lport.c
> +++ b/ovn/controller/lport.c
> @@ -68,6 +68,10 @@ lport_index_init(struct lport_index *lports, struct
> ovsdb_idl *ovnsb_idl)
>  void
>  lport_index_destroy(struct lport_index *lports)
>  {
> +    if (!lports) {
> +        return;
> +    }
> +
>      /* Destroy all of the "struct lport"s.
>       *
>       * We don't have to remove the node from both indexes. */
> @@ -141,6 +145,10 @@ mcgroup_index_init(struct mcgroup_index *mcgroups,
> struct ovsdb_idl *ovnsb_idl)
>  void
>  mcgroup_index_destroy(struct mcgroup_index *mcgroups)
>  {
> +    if (!mcgroups) {
> +        return;
> +    }
> +
>      struct mcgroup *mcgroup, *next;
>      HMAP_FOR_EACH_SAFE (mcgroup, next, dp_name_node,
> &mcgroups->by_dp_name) {
>          hmap_remove(&mcgroups->by_dp_name, &mcgroup->dp_name_node);
> --
> 2.10.2
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
diff mbox

Patch

diff --git a/ovn/controller/lport.c b/ovn/controller/lport.c
index 3484c2c..38aca22 100644
--- a/ovn/controller/lport.c
+++ b/ovn/controller/lport.c
@@ -68,6 +68,10 @@  lport_index_init(struct lport_index *lports, struct ovsdb_idl *ovnsb_idl)
 void
 lport_index_destroy(struct lport_index *lports)
 {
+    if (!lports) {
+        return;
+    }
+
     /* Destroy all of the "struct lport"s.
      *
      * We don't have to remove the node from both indexes. */
@@ -141,6 +145,10 @@  mcgroup_index_init(struct mcgroup_index *mcgroups, struct ovsdb_idl *ovnsb_idl)
 void
 mcgroup_index_destroy(struct mcgroup_index *mcgroups)
 {
+    if (!mcgroups) {
+        return;
+    }
+
     struct mcgroup *mcgroup, *next;
     HMAP_FOR_EACH_SAFE (mcgroup, next, dp_name_node, &mcgroups->by_dp_name) {
         hmap_remove(&mcgroups->by_dp_name, &mcgroup->dp_name_node);