From: Ben Pfaff Date: Tue, 16 Nov 2010 19:05:48 +0000 (-0800) Subject: openflow: Change ofp_phy_port's 'name' member from uint8_t[] to char[]. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b61210ecb328274be67c23127e15af0809b00da;p=openvswitch openflow: Change ofp_phy_port's 'name' member from uint8_t[] to char[]. The uint8_t type here has bothered me from the very beginning. --- diff --git a/include/openflow/openflow.h b/include/openflow/openflow.h index f84fd020..3db5d356 100644 --- a/include/openflow/openflow.h +++ b/include/openflow/openflow.h @@ -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. */ diff --git a/lib/learning-switch.c b/lib/learning-switch.c index ef715dba..511096ab 100644 --- a/lib/learning-switch.c +++ b/lib/learning-switch.c @@ -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, diff --git a/lib/ofp-print.c b/lib/ofp-print.c index f6560747..e3cae783 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -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); diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index bf557cfc..2b2a306a 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -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 : ""; + const char *name = ofport ? ofport->opp.name : ""; 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); } diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 54e4b0c3..80e3eb39 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -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);