diff options
author | Martin Schwenke <martin@meltin.net> | 2018-04-26 20:32:30 +1000 |
---|---|---|
committer | Martin Schwenke <martins@samba.org> | 2018-05-01 13:31:18 +0200 |
commit | 518be6d5a26771040801f76db1279912128f3bc1 (patch) | |
tree | e8e1321dd07ee5cd368a4a55af6030ecaf9100f2 /ctdb/server/ctdbd.c | |
parent | 7052f87903fc5daaad2e155f345800ee897d19b2 (diff) | |
download | samba-518be6d5a26771040801f76db1279912128f3bc1.tar.gz |
ctdb-daemon: Use a local variable instead of repeating getenv()
Makes the error handling easier and the code more compact.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/server/ctdbd.c')
-rw-r--r-- | ctdb/server/ctdbd.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c index 38a5f9d3935..4a3c5f65b30 100644 --- a/ctdb/server/ctdbd.c +++ b/ctdb/server/ctdbd.c @@ -141,6 +141,7 @@ int main(int argc, const char *argv[]) const char **extra_argv; poptContext pc; struct tevent_context *ev; + const char *ctdb_base; /* Environment variable overrides default */ ctdbd_pidfile = getenv("CTDB_PIDFILE"); @@ -280,10 +281,14 @@ int main(int argc, const char *argv[]) /* Default value for CTDB_BASE - don't override */ setenv("CTDB_BASE", CTDB_ETCDIR, 0); + ctdb_base = getenv("CTDB_BASE"); + if (ctdb_base == NULL) { + D_ERR("CTDB_BASE not set\n"); + exit(1); + } /* tell ctdb what nodes are available */ - ctdb->nodes_file = - talloc_asprintf(ctdb, "%s/nodes", getenv("CTDB_BASE")); + ctdb->nodes_file = talloc_asprintf(ctdb, "%s/nodes", ctdb_base); if (ctdb->nodes_file == NULL) { DEBUG(DEBUG_ERR,(__location__ " Out of memory\n")); exit(1); @@ -301,7 +306,7 @@ int main(int argc, const char *argv[]) ctdb->event_script_dir = talloc_asprintf(ctdb, "%s/events.d", - getenv("CTDB_BASE")); + ctdb_base); if (ctdb->event_script_dir == NULL) { DBG_ERR("Out of memory\n"); exit(1); |