openflow: Change ofp_phy_port's 'name' member from uint8_t[] to char[].
authorBen Pfaff <blp@nicira.com>
Tue, 16 Nov 2010 19:05:48 +0000 (11:05 -0800)
committerBen Pfaff <blp@nicira.com>
Thu, 2 Dec 2010 22:57:04 +0000 (14:57 -0800)
The uint8_t type here has bothered me from the very beginning.

include/openflow/openflow.h
lib/learning-switch.c
lib/ofp-print.c
ofproto/ofproto.c
utilities/ovs-ofctl.c

index f84fd0202e245160e71a9f9ce29817539f3ffc89..3db5d356ecacf6067db6774b62bab3320cbe4f41 100644 (file)
@@ -216,7 +216,7 @@ enum ofp_port_features {
 struct ofp_phy_port {
     uint16_t port_no;
     uint8_t hw_addr[OFP_ETH_ALEN];
-    uint8_t name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
+    char name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
 
     uint32_t config;        /* Bitmap of OFPPC_* flags. */
     uint32_t state;         /* Bitmap of OFPPS_* flags. */
index ef715dbabc1052e8fa2a7caf6d08a50d36e65ee3..511096ab8e798639eecd996fe4ca305e3bb44e15 100644 (file)
@@ -297,7 +297,7 @@ process_switch_features(struct lswitch *sw, struct rconn *rconn OVS_UNUSED,
         struct lswitch_port *lp;
 
         opp->name[OFP_MAX_PORT_NAME_LEN - 1] = '\0';
-        lp = shash_find_data(&sw->queue_names, (char *) opp->name);
+        lp = shash_find_data(&sw->queue_names, opp->name);
         if (lp && hmap_node_is_null(&lp->hmap_node)) {
             lp->port_no = ntohs(opp->port_no);
             hmap_insert(&sw->queue_numbers, &lp->hmap_node,
index f6560747e492076272167a3bc71b6ad24843c39a..e3cae783168d83b0c1d73e75964e1e14f4817d02 100644 (file)
@@ -565,7 +565,7 @@ static void ofp_print_port_features(struct ds *string, uint32_t features)
 static void
 ofp_print_phy_port(struct ds *string, const struct ofp_phy_port *port)
 {
-    uint8_t name[OFP_MAX_PORT_NAME_LEN];
+    char name[OFP_MAX_PORT_NAME_LEN];
     int j;
 
     memcpy(name, port->name, sizeof name);
index bf557cfc3b01544f4876fc6693898f69e94d65a1..2b2a306a03ed815c8e87194bfe85577c93dfacdd 100644 (file)
@@ -1316,7 +1316,7 @@ int
 ofproto_port_del(struct ofproto *ofproto, uint16_t odp_port)
 {
     struct ofport *ofport = get_port(ofproto, odp_port);
-    const char *name = ofport ? (char *) ofport->opp.name : "<unknown>";
+    const char *name = ofport ? ofport->opp.name : "<unknown>";
     int error;
 
     error = dpif_port_del(ofproto->dpif, odp_port);
@@ -1439,7 +1439,7 @@ reinit_ports(struct ofproto *p)
 
     svec_init(&devnames);
     HMAP_FOR_EACH (ofport, hmap_node, &p->ports) {
-        svec_add (&devnames, (char *) ofport->opp.name);
+        svec_add (&devnames, ofport->opp.name);
     }
     dpif_port_list(p->dpif, &odp_ports, &n_odp_ports);
     for (i = 0; i < n_odp_ports; i++) {
@@ -1521,7 +1521,7 @@ ofport_equal(const struct ofport *a_, const struct ofport *b_)
     BUILD_ASSERT_DECL(sizeof *a == 48); /* Detect ofp_phy_port changes. */
     return (a->port_no == b->port_no
             && !memcmp(a->hw_addr, b->hw_addr, sizeof a->hw_addr)
-            && !strcmp((char *) a->name, (char *) b->name)
+            && !strcmp(a->name, b->name)
             && a->state == b->state
             && a->config == b->config
             && a->curr == b->curr
@@ -1558,7 +1558,7 @@ send_port_status(struct ofproto *p, const struct ofport *ofport,
 static void
 ofport_install(struct ofproto *p, struct ofport *ofport)
 {
-    const char *netdev_name = (const char *) ofport->opp.name;
+    const char *netdev_name = ofport->opp.name;
 
     netdev_monitor_add(p->netdev_monitor, ofport->netdev);
     hmap_insert(&p->ports, &ofport->hmap_node, hash_int(ofport->odp_port, 0));
@@ -1574,7 +1574,7 @@ ofport_remove(struct ofproto *p, struct ofport *ofport)
     netdev_monitor_remove(p->netdev_monitor, ofport->netdev);
     hmap_remove(&p->ports, &ofport->hmap_node);
     shash_delete(&p->port_by_name,
-                 shash_find(&p->port_by_name, (char *) ofport->opp.name));
+                 shash_find(&p->port_by_name, ofport->opp.name));
     if (p->sflow) {
         ofproto_sflow_del_port(p->sflow, ofport->odp_port);
     }
index 54e4b0c329c216bae9f8546f33d6af3081a1b31d..80e3eb392bd4ab076c6dbe265cfd75416f0f6642 100644 (file)
@@ -440,7 +440,7 @@ fetch_ofp_phy_port(const char *vconn_name, const char *port_name,
 
         if (port_no != UINT_MAX
             ? htons(port_no) == opp->port_no
-            : !strncmp((char *) opp->name, port_name, sizeof opp->name)) {
+            : !strncmp(opp->name, port_name, sizeof opp->name)) {
             *oppp = *opp;
             ofpbuf_delete(reply);
             vconn_close(vconn);