[ovs-dev] [next 31/35] dpif: Make dp_parse_name() normalize its returned type.

Ben Pfaff blp at nicira.com
Tue Apr 26 16:24:57 UTC 2011


This means that callers don't have to be concerned with a NULL return value
or unnormalized type.
---
 lib/dpif.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/dpif.c b/lib/dpif.c
index aaa8075..215ecfc 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -200,8 +200,10 @@ dp_enumerate_names(const char *type, struct sset *names)
     return error;
 }
 
-/* Parses 'datapath name', which is of the form type at name into its
- * component pieces.  'name' and 'type' must be freed by the caller. */
+/* Parses 'datapath_name_', which is of the form [type@]name into its
+ * component pieces.  'name' and 'type' must be freed by the caller.
+ *
+ * The returned 'type' is normalized, as if by dpif_normalize_type(). */
 void
 dp_parse_name(const char *datapath_name_, char **name, char **type)
 {
@@ -212,10 +214,10 @@ dp_parse_name(const char *datapath_name_, char **name, char **type)
     if (separator) {
         *separator = '\0';
         *type = datapath_name;
-        *name = xstrdup(separator + 1);
+        *name = xstrdup(dpif_normalize_type(separator + 1));
     } else {
         *name = datapath_name;
-        *type = NULL;
+        *type = xstrdup(dpif_normalize_type(NULL));
     }
 }
 
-- 
1.7.4.4




More information about the dev mailing list