[ovs-dev] [PATCH] dpif: Avoid use of "struct ovs_dp_stats" in platform-independent modules.

Ben Pfaff blp at nicira.com
Wed Oct 5 18:19:20 UTC 2011


On Tue, Oct 04, 2011 at 07:03:12PM -0700, Jesse Gross wrote:
> On Tue, Oct 4, 2011 at 7:02 PM, Ben Pfaff <blp at nicira.com> wrote:
> > On Tue, Oct 04, 2011 at 06:47:23PM -0700, Jesse Gross wrote:
> >> On Tue, Oct 4, 2011 at 2:17 PM, Ben Pfaff <blp at nicira.com> wrote:
> >> > diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c
> >> > index c104dfd..9414dec 100644
> >> > --- a/lib/dpif-linux.c
> >> > +++ b/lib/dpif-linux.c
> >> > @@ -338,7 +338,12 @@ dpif_linux_get_stats(const struct dpif *dpif_, struct ovs_dp_stats *stats)
> >> >
> >> > ?? ?? error = dpif_linux_dp_get(dpif_, &dp, &buf);
> >> > ?? ?? if (!error) {
> >> > - ?? ?? ?? ??*stats = dp.stats;
> >> > + ?? ?? ?? ??memset(stats, 0, sizeof *stats);
> >> > + ?? ?? ?? ??stats->n_frags ??= dp.stats.n_frags;
> >> > + ?? ?? ?? ??stats->n_hit ?? ??= dp.stats.n_hit;
> >> > + ?? ?? ?? ??stats->n_missed = dp.stats.n_missed;
> >> > + ?? ?? ?? ??stats->n_lost ?? = dp.stats.n_lost;
> >> > + ?? ?? ?? ??stats->n_flows ??= dp.stats.n_flows;
> >>
> >> I'm not quite sure why we memset the stats struct to 0 before setting
> >> all of the fields although I see that we do the same thing in
> >> dpif-netdev.c.
> >
> > It's just conservative future-proofing against adding fields later.
> > But that's kind of silly (any "grep" will find these users), so I'm
> > just happy to remove them if you like.
> 
> It doesn't really matter, it just looked a little strange to me.  I
> think this patch is good either way.

I decided to just delete the memset from both places.  I'll push this
soon.



More information about the dev mailing list