[ovs-dev] [PATCH 1/3] netdev-linux: Fix tap device stats.

Ben Pfaff blp at nicira.com
Tue Jun 1 23:25:43 UTC 2010


On Tue, Jun 01, 2010 at 04:17:38PM -0700, Jesse Gross wrote:
> For tap and internal devices we swap the transmit and receive stats
> to appear consistent with other devices.  However, the check whether
> to store the stats in a temporary location before the swap did not
> include tap devices, which lead to the use of uninitialized memory
> when the swap occured.

It looks OK, except that the doubled parentheses look funny and
shouldn't be necessary.

But the real problem is the duplication of the condition in two
different places.  We could avoid the problem entirely by either:

        * Adding a "bool swap_stats" variable, so that the full
          condition would only appear at the top of the function, or

        * Not using temporaries at all (probably adding a swap_uint64()
          helper function), so that we'd only need to check in one place
          anyway.

I'm kind of partial to the second solution, but I don't really care.




More information about the dev mailing list