[ovs-dev] [PATCH 01/45] openflow: Add enum ofp_version
Ben Pfaff
blp at nicira.com
Tue Jul 31 04:32:09 UTC 2012
On Mon, Jul 30, 2012 at 11:02:59AM +0900, Simon Horman wrote:
> Use an enum for ofp_version in ofp-util and ofp-msg.
> This in conjunction with the use of switch() statements
> allows the compiler to warn when a new ofp_version isn't handled.
>
> Signed-off-by: Simon Horman <horms at verge.net.au>
>
> ---
>
> Anecdotally, this type of approach has proved to be quite useful
> in my work adding support for Open Flow 1.2 messages.
"sparse" reported:
../ofproto/ofproto.c:2307:65: warning: mixing different enum types
../ofproto/ofproto.c:2307:65: int enum ofputil_protocol versus
../ofproto/ofproto.c:2307:65: int enum ofp_version
so I folded this in:
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 5fa57d8..0f24fd0 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -2298,14 +2298,15 @@ handle_port_desc_stats_request(struct ofconn *ofconn,
const struct ofp_header *request)
{
struct ofproto *p = ofconn_get_ofproto(ofconn);
+ enum ofp_version version;
struct ofport *port;
struct list replies;
ofpmp_init(&replies, request);
+ version = ofputil_protocol_to_ofp_version(ofconn_get_protocol(ofconn));
HMAP_FOR_EACH (port, hmap_node, &p->ports) {
- ofputil_append_port_desc_stats_reply(ofconn_get_protocol(ofconn),
- &port->pp, &replies);
+ ofputil_append_port_desc_stats_reply(version, &port->pp, &replies);
}
ofconn_send_replies(ofconn, &replies);
and plan to apply it.
More information about the dev
mailing list