From: Ben Pfaff Date: Thu, 16 Dec 2010 19:12:03 +0000 (-0800) Subject: nx-match: Use [] in format_nxm_field_bits where possible. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=21dd5f55a40fa16e4d9fae1a354f51b0a2992e22;p=openvswitch nx-match: Use [] in format_nxm_field_bits where possible. This just makes formatting a bit more readable. --- diff --git a/lib/nx-match.c b/lib/nx-match.c index 04c75b8b..7d7abb22 100644 --- a/lib/nx-match.c +++ b/lib/nx-match.c @@ -950,10 +950,12 @@ static void format_nxm_field_bits(struct ds *s, uint32_t header, int ofs, int n_bits) { format_nxm_field_name(s, header); - if (n_bits != 1) { - ds_put_format(s, "[%d..%d]", ofs, ofs + n_bits - 1); - } else { + if (ofs == 0 && n_bits == nxm_field_bits(header)) { + ds_put_cstr(s, "[]"); + } else if (n_bits == 1) { ds_put_format(s, "[%d]", ofs); + } else { + ds_put_format(s, "[%d..%d]", ofs, ofs + n_bits - 1); } } diff --git a/tests/ovs-ofctl.at b/tests/ovs-ofctl.at index 94013e7a..563a7c6b 100644 --- a/tests/ovs-ofctl.at +++ b/tests/ovs-ofctl.at @@ -105,7 +105,7 @@ NXT_FLOW_MOD: ADD cookie:0x123456789abcdef hard:10 pri:60000 actions=CONTR NXT_FLOW_MOD: ADD actions=note:41.42.43.00.00.00,note:00.01.02.03.04.05.06.07.00.00.00.00.00.00,note:00.00.00.00.00.00 NXT_FLOW_MOD: ADD NXM_NX_TUN_ID(0000000000001234) cookie:0x5678 actions=FLOOD NXT_FLOW_MOD: ADD actions=drop -NXT_FLOW_MOD: ADD NXM_NX_REG0(0000007b) actions=move:NXM_NX_REG0[0..5]->NXM_NX_REG1[26..31],load:55->NXM_NX_REG2[0..31],move:NXM_NX_REG0[0..31]->NXM_NX_TUN_ID[0..31],move:NXM_NX_REG0[0..15]->NXM_OF_VLAN_TCI[0..15] +NXT_FLOW_MOD: ADD NXM_NX_REG0(0000007b) actions=move:NXM_NX_REG0[0..5]->NXM_NX_REG1[26..31],load:55->NXM_NX_REG2[],move:NXM_NX_REG0[]->NXM_NX_TUN_ID[0..31],move:NXM_NX_REG0[0..15]->NXM_OF_VLAN_TCI[] ]]) AT_CLEANUP