Yes, please give it a try.
On Aug 22, 2013 11:30 AM, "Alex Wang" <[email protected]> wrote:

> Can I have a try and see how cleaner it would be if we use "uint16_t"?
>
>
> On Thu, Aug 22, 2013 at 11:19 AM, Ben Pfaff <[email protected]> wrote:
>
>> 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 <[email protected]>
>> ---
>>  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
>>
>> _______________________________________________
>> dev mailing list
>> [email protected]
>> http://openvswitch.org/mailman/listinfo/dev
>>
>
>
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to