[ovs-dev] [PATCH 3/3] ovn-controller-vtep: Make 'ovnsb_remote' and 'vtep_remote' free-able.
Russell Bryant
rbryant at redhat.com
Tue Aug 18 15:19:53 UTC 2015
On 08/17/2015 11:29 PM, Alex Wang wrote:
> Found by inspection.
>
> Signed-off-by: Alex Wang <alexw at nicira.com>
> ---
> ovn/controller-vtep/ovn-controller-vtep.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/ovn/controller-vtep/ovn-controller-vtep.c b/ovn/controller-vtep/ovn-controller-vtep.c
> index ff25319..a42122b 100644
> --- a/ovn/controller-vtep/ovn-controller-vtep.c
> +++ b/ovn/controller-vtep/ovn-controller-vtep.c
> @@ -189,11 +189,11 @@ parse_options(int argc, char *argv[])
>
> switch (c) {
> case 'd':
> - ovnsb_remote = optarg;
> + ovnsb_remote = xstrdup(optarg);
> break;
>
> case 'D':
> - vtep_remote = optarg;
> + vtep_remote = xstrdup(optarg);
> break;
>
> case 'h':
> @@ -224,11 +224,11 @@ parse_options(int argc, char *argv[])
> argv += optind;
>
> if (!ovnsb_remote) {
> - ovnsb_remote = default_db();
> + ovnsb_remote = xstrdup(default_db());
> }
>
> if (!vtep_remote) {
> - vtep_remote = default_db();
> + vtep_remote = xstrdup(default_db());
> }
> }
>
>
While you're at it, would you like to make sure the result of
default_db() gets freed too? With this change, the free() calls are now
all correct, but it leaves default_db() not cleaned up.
Maybe something like ...
static char *default_db_;
static char *
default_db(void)
{
if (!default_db_) {
default_db_ = xasprintf("unix:%s/db.sock", ovs_rundir());
}
return default_db_;
}
.... later in main() during cleanup before exit() ...
free(default_db_);
--
Russell Bryant
More information about the dev
mailing list