From: Ben Pfaff Date: Wed, 6 Jan 2010 22:20:19 +0000 (-0800) Subject: Check invariants earlier in vconn and stream code. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0668bd1d448d6f17c20b9c7ba91344180809061;p=openvswitch Check invariants earlier in vconn and stream code. 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. --- diff --git a/lib/stream.c b/lib/stream.c index 23b25f22..337fb5c7 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 b11650fb..7b9ae610 100644 --- a/lib/vconn.c +++ b/lib/vconn.c @@ -1444,6 +1444,7 @@ 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