ctdb-tests: Use path_socket() in test client tools
authorMartin Schwenke <martin@meltin.net>
Fri, 6 Jul 2018 05:30:31 +0000 (15:30 +1000)
committerAmitay Isaacs <amitay@samba.org>
Tue, 6 Nov 2018 06:16:14 +0000 (07:16 +0100)
Just leak the memory allocated by path_socket().  This is only used in
short-lived test programs, so it isn't worth the hassle of plumbing a
talloc context through several layers to get here.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/src/test_options.c

index e732a79c8ff378f2655bd59281335bdb4e90fdf3..cfce51aeeb62869350956ec57a23a9bfa175c12b 100644 (file)
 
 #include "replace.h"
 
 
 #include "replace.h"
 
+#include <assert.h>
 #include <popt.h>
 #include <talloc.h>
 
 #include "lib/util/debug.h"
 
 #include "common/logging.h"
 #include <popt.h>
 #include <talloc.h>
 
 #include "lib/util/debug.h"
 
 #include "common/logging.h"
+#include "common/path.h"
 
 #include "tests/src/test_options.h"
 
 
 #include "tests/src/test_options.h"
 
@@ -66,19 +68,14 @@ static struct poptOption options_database[] = {
 
 static void set_defaults_basic(struct test_options *opts)
 {
 
 static void set_defaults_basic(struct test_options *opts)
 {
-       const char *ctdb_socket;
-
        /* Set default options */
        /* Set default options */
-       opts->socket = CTDB_SOCKET;
+       opts->socket = path_socket(NULL, "ctdbd"); /* leaked */
+       assert(opts->socket != NULL);
+
        opts->timelimit = 10;
        opts->num_nodes = 1;
        opts->debugstr = "ERR";
        opts->interactive = 0;
        opts->timelimit = 10;
        opts->num_nodes = 1;
        opts->debugstr = "ERR";
        opts->interactive = 0;
-
-       ctdb_socket = getenv("CTDB_SOCKET");
-       if (ctdb_socket != NULL) {
-               opts->socket = ctdb_socket;
-       }
 }
 
 static void set_defaults_database(struct test_options *opts)
 }
 
 static void set_defaults_database(struct test_options *opts)