> In ofp_print_packet_in(), the use of ~ (twice) below makes me nervous.
> Testing the result of ~ for a nonzero value is risky, because C's
> promotion rules mean that it will always be true due if the expression's
> type is narrower than "int". That should not ever be the case here, but
> I think I still would prefer explicit comparisons against
> e.g. htonll(UINT64_MAX), because it requires less thinking to see that
> it is correct:
I agree so I changed it to an explicit comparison against
htonll(UINT64_MAX) and UINT32_MAX as appropriate.
Ethan
>
>> + if (pin.fmd.tun_id_mask) {
>> + ds_put_format(string, " tun_id=0x%"PRIx64, ntohll(pin.fmd.tun_id));
>> + if (~pin.fmd.tun_id_mask) {
>> + ds_put_format(string, "/0x%"PRIx64,
>> ntohll(pin.fmd.tun_id_mask));
>> + }
>> + }
>> +
>> + for (i = 0; i < FLOW_N_REGS; i++) {
>> + if (pin.fmd.reg_masks[i]) {
>> + ds_put_format(string, " reg%d=0x%"PRIx32, i, pin.fmd.regs[i]);
>> + if (~pin.fmd.reg_masks[i]) {
>> + ds_put_format(string, "/0x%"PRIx32, pin.fmd.reg_masks[i]);
>> + }
>> + }
>> + }
>
> Thanks,
>
> Ben.
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev