[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openvswitch-dev
Subject:    [ovs-dev] [PATCH 2/9] Check invariants earlier in vconn and stream code.
From:       blp () nicira ! com (Ben Pfaff)
Date:       2009-12-21 21:15:42
Message-ID: 1261430149-11340-2-git-send-email-blp () nicira ! com
[Download RAW message or body]

These invariants are checked by vconn_open() and stream_open(), but there
is no reason not to check them earlier also.  vconn and stream creation
don't have to go through vconn_open() and stream_open(), so this ensures
that the invariants get checked either way.
---
 lib/stream.c |    1 +
 lib/vconn.c  |    2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/lib/stream.c b/lib/stream.c
index 23b25f2..337fb5c 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -476,6 +476,7 @@ stream_init(struct stream *stream, struct stream_class *class,
                     : SCS_DISCONNECTED);
     stream->error = connect_status;
     stream->name = xstrdup(name);
+    assert(stream->state != SCS_CONNECTING || class->connect);
 }
 
 void
diff --git a/lib/vconn.c b/lib/vconn.c
index b11650f..1c440fb 100644
--- a/lib/vconn.c
+++ b/lib/vconn.c
@@ -1444,6 +1444,8 @@ vconn_init(struct vconn *vconn, struct vconn_class *class, int connect_status,
     vconn->local_ip = 0;
     vconn->local_port = 0;
     vconn->name = xstrdup(name);
+    assert(vconn->state != VCS_CONNECTING || class->connect);
+
 }
 
 void
-- 
1.6.3.3




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic