[ovs-dev] [PATCH 12/16] netdev-linux: Check notifications are for netdev-linux device.

Jesse Gross jesse at nicira.com
Wed Apr 14 18:40:56 UTC 2010


On Wed, Apr 14, 2010 at 2:14 PM, Ben Pfaff <blp at nicira.com> wrote:

> On Tue, Apr 13, 2010 at 10:41:14AM -0400, Jesse Gross wrote:
> > diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
> > index 736b588..2fc5b09 100644
> > --- a/lib/netdev-linux.c
> > +++ b/lib/netdev-linux.c
> > @@ -175,18 +175,21 @@ static int get_stats_via_proc(const char
> *netdev_name, struct netdev_stats *stat
> >  static struct netdev_dev_linux *
> >  netdev_dev_linux_cast(const struct netdev_dev *netdev_dev)
> >  {
> > -    const char *type = netdev_dev_get_type(netdev_dev);
> > -    assert(!strcmp(type, "system") || !strcmp(type, "tap")
> > -            || !strcmp(type, "gre"));
> > +    const struct netdev_class *netdev_class =
> netdev_dev_get_class(netdev_dev);
> > +    assert(netdev_class == &netdev_linux_class
> > +            || netdev_class == &netdev_tap_class
> > +            || netdev_class == &netdev_gre_class);
>
> I would move the test into a function, e.g. is_netdev_dev_linux() and
> then assert(is_netdev_dev_linux(netdev_class)); or similar.
>
> I would consider simplifying the test to something like
> netdev_class->init == netdev_linux_init.
>

Good ideas, thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20100414/fe1c3508/attachment-0003.html>


More information about the dev mailing list