summaryrefslogtreecommitdiff
path: root/lib/flow.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2017-04-14 21:25:41 -0700
committerBen Pfaff <blp@ovn.org>2017-04-21 15:44:43 -0700
commit68c744fd30656e3c3ed6a30f7b4de6e99dc9f790 (patch)
tree54a671f1b633b44de08511c08b45da8de2b7bc1f /lib/flow.c
parentbc3436de9ae2a57952982ae280479c38b9cec228 (diff)
downloadopenvswitch-68c744fd30656e3c3ed6a30f7b4de6e99dc9f790.tar.gz
flow: Further refinements to flow_pop_vlan().
This may help to suppress warnings from know-it-all compilers, and it helps to make the code clearer too. Reported-by: Darrell Ball <dlu998@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Eric Garver <e@erig.me>
Diffstat (limited to 'lib/flow.c')
-rw-r--r--lib/flow.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/flow.c b/lib/flow.c
index 2ba51214e..07b13976e 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -2226,16 +2226,17 @@ void
flow_pop_vlan(struct flow *flow, struct flow_wildcards *wc)
{
int n = flow_count_vlan_headers(flow);
- if (n == 0) {
- return;
+ if (n > 1) {
+ if (wc) {
+ memset(&wc->masks.vlans[1], 0xff,
+ sizeof(union flow_vlan_hdr) * (n - 1));
+ }
+ memmove(&flow->vlans[0], &flow->vlans[1],
+ sizeof(union flow_vlan_hdr) * (n - 1));
}
- if (wc) {
- memset(&wc->masks.vlans[1], 0xff,
- sizeof(union flow_vlan_hdr) * (n - 1));
+ if (n > 0) {
+ memset(&flow->vlans[n - 1], 0, sizeof(union flow_vlan_hdr));
}
- memmove(&flow->vlans[0], &flow->vlans[1],
- sizeof(union flow_vlan_hdr) * (n - 1));
- memset(&flow->vlans[n - 1], 0, sizeof(union flow_vlan_hdr));
}
void