[ovs-dev] [PATCH] ofproto: Fix sparse warnings about treating ofp_port_t as integer.
Ben Pfaff
blp at nicira.com
Thu Aug 22 18:19:08 UTC 2013
Fixes the following sparse warnings introduced by commit 7c35397c84d
(ofproto: Start ofport allocation from the previous max after restart.)
ofproto.c:2106:58: warning: restricted ofp_port_t degrades to integer
ofproto.c:2107:40: warning: restricted ofp_port_t degrades to integer
ofproto.c:2107:40: warning: restricted ofp_port_t degrades to integer
ofproto.c:2107:38: warning: incorrect type in assignment (different base types)
ofproto.c:2107:38: expected restricted ofp_port_t [usertype] alloc_port_no
ofproto.c:2107:38: got int
This fix makes the code uglier. Maybe we should make 'alloc_port_no'
and 'max_ports' "uint16_t"s instead of "ofp_port_t"s.
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
ofproto/ofproto.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 947b8c6..468e08e 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -2103,9 +2103,11 @@ init_ports(struct ofproto *p)
netdev = ofport_open(p, &ofproto_port, &pp);
if (netdev) {
ofport_install(p, netdev, &pp);
- if (ofproto_port.ofp_port < p->max_ports) {
- p->alloc_port_no = MAX(p->alloc_port_no,
- ofproto_port.ofp_port);
+ if (ofp_to_u16(ofproto_port.ofp_port)
+ < ofp_to_u16(p->max_ports)) {
+ p->alloc_port_no = u16_to_ofp(
+ MAX(ofp_to_u16(p->alloc_port_no),
+ ofp_to_u16(ofproto_port.ofp_port)));
}
}
}
--
1.7.10.4
More information about the dev
mailing list