From d2a345699f3951029941d01c7f1bf008d706ad20 Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Fri, 7 Aug 2009 11:09:56 -0700 Subject: [PATCH] dpif: Only clear 'all_dps' argument in dp_enumerate(). 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 | 8 ++++---- vswitchd/bridge.c | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/dpif.c b/lib/dpif.c index 14b424e6..e823fa34 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -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]; diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 6b05d132..22fe19a0 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -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]; -- 2.30.2