]> git.proxmox.com Git - mirror_ovs.git/commitdiff
dpif: Only clear 'all_dps' argument in dp_enumerate().
authorJustin Pettit <jpettit@nicira.com>
Fri, 7 Aug 2009 18:09:56 +0000 (11:09 -0700)
committerJustin Pettit <jpettit@nicira.com>
Fri, 7 Aug 2009 18:16:06 +0000 (11:16 -0700)
Originally, the function dp_enumerate() initialized the 'all_dps'
argument.  This is inconsistent with most other functions that take an
svec argument, which would only clear the contents.  Further, if someone
were not careful when reusing the svec, it could lead to memory leaks.
With this change, the caller is expected to first call svec_init() on
the argument.

lib/dpif.c
vswitchd/bridge.c

index 14b424e65c3948a993c2bc0a36d41c0c4d8896ef..e823fa348a5183b6a10a57b07cadde1a2315f0b5 100644 (file)
@@ -95,9 +95,9 @@ dp_wait(void)
     }
 }
 
-/* Initializes 'all_dps' and enumerates the names of all known created
- * datapaths, where possible, into it.  Returns 0 if successful, otherwise a
- * positive errno value.
+/* Clears 'all_dps' and enumerates the names of all known created datapaths, 
+ * where possible, into it.  The caller must first initialize 'all_dps'.
+ * Returns 0 if successful, otherwise a positive errno value.
  *
  * Some kinds of datapaths might not be practically enumerable.  This is not
  * considered an error. */
@@ -107,7 +107,7 @@ dp_enumerate(struct svec *all_dps)
     int error;
     int i;
 
-    svec_init(all_dps);
+    svec_clear(all_dps);
     error = 0;
     for (i = 0; i < N_DPIF_CLASSES; i++) {
         const struct dpif_class *class = dpif_classes[i];
index 6b05d13278bb78b37fb89101aff5fda65bed1b2b..22fe19a0427ed1520bde0247d648d487bde591b1 100644 (file)
@@ -285,6 +285,7 @@ bridge_init(void)
 
     unixctl_command_register("fdb/show", bridge_unixctl_fdb_show);
 
+    svec_init(&dpif_names);
     dp_enumerate(&dpif_names);
     for (i = 0; i < dpif_names.n; i++) {
         const char *dpif_name = dpif_names.names[i];