Looks Good.
On Tue, Apr 26, 2011 at 09:24, Ben Pfaff <b...@nicira.com> wrote: > This allows dpif types to be compared. > --- > lib/dpif.c | 14 +++++++++++--- > lib/dpif.h | 2 ++ > 2 files changed, 13 insertions(+), 3 deletions(-) > > diff --git a/lib/dpif.c b/lib/dpif.c > index 81e180f..26d3dc2 100644 > --- a/lib/dpif.c > +++ b/lib/dpif.c > @@ -260,9 +260,7 @@ do_open(const char *name, const char *type, bool create, > struct dpif **dpifp) > > dp_initialize(); > > - if (!type || *type == '\0') { > - type = "system"; > - } > + type = dpif_normalize_type(type); > > registered_class = shash_find_data(&dpif_classes, type); > if (!registered_class) { > @@ -363,6 +361,16 @@ dpif_base_name(const struct dpif *dpif) > return dpif->base_name; > } > > +/* Returns the fully spelled out name for the given datapath 'type'. > + * > + * Normalized type string can be compared with strcmp(). Unnormalized type > + * string might be the same even if they have different spellings. */ > +const char * > +dpif_normalize_type(const char *type) > +{ > + return type && type[0] ? type : "system"; > +} > + > /* Destroys the datapath that 'dpif' is connected to, first removing all of > its > * ports. After calling this function, it does not make sense to pass 'dpif' > * to any functions other than dpif_name() or dpif_close(). */ > diff --git a/lib/dpif.h b/lib/dpif.h > index 0e0f407..d6adbc3 100644 > --- a/lib/dpif.h > +++ b/lib/dpif.h > @@ -55,6 +55,8 @@ void dpif_close(struct dpif *); > const char *dpif_name(const struct dpif *); > const char *dpif_base_name(const struct dpif *); > > +const char *dpif_normalize_type(const char *); > + > int dpif_delete(struct dpif *); > > int dpif_get_dp_stats(const struct dpif *, struct odp_stats *); > -- > 1.7.4.4 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev > _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev