Merge commit '4b60911067a82fbdfa87b7c2824412da20287ed8'
[sliver-openvswitch.git] / lib / stp.c
index 06ac001..7bff624 100644 (file)
--- a/lib/stp.c
+++ b/lib/stp.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#include <assert.h>
 #include <inttypes.h>
 #include <stdlib.h>
 #include "byte-order.h"
@@ -151,7 +150,7 @@ stp_next_enabled_port(const struct stp *stp, const struct stp_port *port)
 {
     for (; port < &stp->ports[ARRAY_SIZE(stp->ports)]; port++) {
         if (port->state != STP_DISABLED) {
-            return (struct stp_port *) port;
+            return CONST_CAST(struct stp_port *, port);
         }
     }
     return NULL;
@@ -481,7 +480,7 @@ stp_check_and_reset_fdb_flush(struct stp *stp)
 struct stp_port *
 stp_get_port(struct stp *stp, int port_no)
 {
-    assert(port_no >= 0 && port_no < ARRAY_SIZE(stp->ports));
+    ovs_assert(port_no >= 0 && port_no < ARRAY_SIZE(stp->ports));
     return &stp->ports[port_no];
 }
 
@@ -669,7 +668,7 @@ int
 stp_port_no(const struct stp_port *p)
 {
     struct stp *stp = p->stp;
-    assert(p >= stp->ports && p < &stp->ports[ARRAY_SIZE(stp->ports)]);
+    ovs_assert(p >= stp->ports && p < &stp->ports[ARRAY_SIZE(stp->ports)]);
     return p - stp->ports;
 }
 
@@ -1228,7 +1227,7 @@ stp_hold_timer_expiry(struct stp_port *p)
 static void
 stp_initialize_port(struct stp_port *p, enum stp_state state)
 {
-    assert(state & (STP_DISABLED | STP_BLOCKING));
+    ovs_assert(state & (STP_DISABLED | STP_BLOCKING));
     stp_become_designated_port(p);
     stp_set_port_state(p, state);
     p->topology_change_ack = false;
@@ -1371,7 +1370,7 @@ stp_unixctl_tcn(struct unixctl_conn *conn, int argc,
         struct stp *stp = stp_find(argv[1]);
 
         if (!stp) {
-            unixctl_command_reply(conn, 501, "no such stp object");
+            unixctl_command_reply_error(conn, "no such stp object");
             return;
         }
         stp_topology_change_detection(stp);
@@ -1383,5 +1382,5 @@ stp_unixctl_tcn(struct unixctl_conn *conn, int argc,
         }
     }
 
-    unixctl_command_reply(conn, 200, "OK");
+    unixctl_command_reply(conn, "OK");
 }