[ovs-dev] [tests+nxm-ofctl 19/42] openflow: Change ofp_phy_port's 'name' member from uint8_t[] to char[].

Ethan Jackson ethan at nicira.com
Thu Dec 2 20:43:50 UTC 2010


Looks Good.

On Tue, Nov 23, 2010 at 2:43 PM, Ben Pfaff <blp at nicira.com> wrote:
> The uint8_t type here has bothered me from the very beginning.
> ---
>  include/openflow/openflow.h |    2 +-
>  lib/learning-switch.c       |    2 +-
>  lib/ofp-print.c             |    2 +-
>  ofproto/ofproto.c           |   10 +++++-----
>  utilities/ovs-ofctl.c       |    2 +-
>  5 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/include/openflow/openflow.h b/include/openflow/openflow.h
> index f84fd02..3db5d35 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 ef715db..511096a 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 f656074..e3cae78 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 1d6b222..997509a 100644
> --- a/ofproto/ofproto.c
> +++ b/ofproto/ofproto.c
> @@ -1291,7 +1291,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);
> @@ -1414,7 +1414,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++) {
> @@ -1496,7 +1496,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
> @@ -1530,7 +1530,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));
> @@ -1546,7 +1546,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 54e4b0c..80e3eb3 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);
> --
> 1.7.1
>
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org
>




More information about the dev mailing list