On Fri, 2022-07-08 at 09:38 +0800, Jianbo Liu wrote:
> On Thu, 2022-07-07 at 14:02 +0200, Ilya Maximets wrote:
> > On 7/7/22 13:51, Eelco Chaudron wrote:
> > > On 2 Jul 2022, at 5:18, Jianbo Liu wrote:
> > > > +static int
> > > > +tc_update_policer_action_stats(struct ofpbuf *msg,
> > > > + struct ofputil_meter_stats
> > > > *stats)
> > > > +{
> > > > + struct ovs_flow_stats stats_dropped = {0};
> > > > + struct ovs_flow_stats stats_hw = {0};
> > > > + struct ovs_flow_stats stats_sw = {0};
> > >
> > > Here you want to keep the initializer as {}, as setting it to {0}
> > > gets
> > > some compilers to only initialize the first element. See also the
> > > robot
> > > complaining about this.
> > I don't think empty braces is a valid initializer from the
> > standard C point of view. We should use memset or a valid
> > designated initializer with at least one field specified.
> >
> > OTOH, do we really need these to be initialized?
> > If the tc_parse_action_stats() call fails, we're not using
> > them, but if it succeeds, they should be initialized with
> > valid values by the function.
> >
>
> In tc_parse_action_stats(), we parse stats by stats_policy. And
> TCA_STATS_BASIC_HW and TCA_STATS_QUEUE are defined as optional in it.
> From this logic, we should init stats_hw and stats_dropped (not need
> for stats_sw), in case we can't parse them out of stats.
>
Looks stats_sw also need initialization. It may not set any value in
tc_parse_action_stats().
> I used {} in v5, and {0} in v6. Both doesn't work. Maybe {{0},{0}}
> could work. But I prefer to memset. Will use memset in v7.
>
> Thanks!
>
> > Best regards, Ilya Maximets.
>
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev