From e467ea42c4b2b98e4b106cbb651db2699ca127d6 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 29 Jul 2015 22:31:07 -0700 Subject: [PATCH] ofproto-dpif-xlate: Initialize '*xout' all together at beginning. To my mind, this is a good way to ensure that '*xout' gets initialized properly in every execution. By using an initializer rather than a series of assignment statements, we can be assured that every member gets initialized. This commit makes xlate_actions() more expensive because struct xlate_out is large and this assignment will initialize all of it due to C rules. Later commits will fix this up by removing all of the large members, reducing xlate_out to only a few bytes total. Signed-off-by: Ben Pfaff Acked-by: Jarno Rajahalme --- ofproto/ofproto-dpif-xlate.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 125d4c68a..b6d5d1533 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -4720,6 +4720,17 @@ too_many_output_actions(const struct ofpbuf *odp_actions OVS_UNUSED) void xlate_actions(struct xlate_in *xin, struct xlate_out *xout) { + *xout = (struct xlate_out) { + .slow = 0, + .fail_open = false, + .has_learn = false, + .has_normal = false, + .has_fin_timeout = false, + .nf_output_iface = NF_OUT_DROP, + .mirrors = 0, + .n_recircs = 0, + }; + struct xlate_cfg *xcfg = ovsrcu_get(struct xlate_cfg *, &xcfgp); struct flow_wildcards *wc = NULL; struct flow *flow = &xin->flow; @@ -4760,13 +4771,6 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout) ctx.xin = xin; ctx.xout = xout; - ctx.xout->slow = 0; - ctx.xout->has_learn = false; - ctx.xout->has_normal = false; - ctx.xout->has_fin_timeout = false; - ctx.xout->nf_output_iface = NF_OUT_DROP; - ctx.xout->mirrors = 0; - ctx.xout->n_recircs = 0; xout->odp_actions = xin->odp_actions; if (!xout->odp_actions) { -- 2.39.5