ctdb: Centralize ctdb_version_string
authorVolker Lendecke <vl@samba.org>
Thu, 21 Sep 2017 18:51:09 +0000 (11:51 -0700)
committerVolker Lendecke <vl@samba.org>
Tue, 26 Sep 2017 07:37:13 +0000 (09:37 +0200)
Whenever the current git hash changes, we recompile ctdb.c and
ctdb_daemon.c. As both have quite a few warnings with -Wall, this
makes it quite difficult to see the real warnings that pop up during
development. Centralize the ctdb_version_string to just a single file
without warnings.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/common/version.c [new file with mode: 0644]
ctdb/common/version.h [new file with mode: 0644]
ctdb/server/ctdb_daemon.c
ctdb/tools/ctdb.c
ctdb/wscript

diff --git a/ctdb/common/version.c b/ctdb/common/version.c
new file mode 100644 (file)
index 0000000..e34e98c
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+   CTDB version string
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "ctdb_version.h"
+
+const char ctdb_version_string[] = CTDB_VERSION_STRING;
diff --git a/ctdb/common/version.h b/ctdb/common/version.h
new file mode 100644 (file)
index 0000000..1cf1c5d
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+   CTDB version string
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+extern const char ctdb_version_string[];
index dda09655e7f244a887a67495457feb0ef66c15b8..185982e65bdfdb463c4321856bd62bdabdbe2248 100644 (file)
@@ -36,7 +36,7 @@
 #include "lib/util/blocking.h"
 #include "lib/util/become_daemon.h"
 
-#include "ctdb_version.h"
+#include "common/version.h"
 #include "ctdb_private.h"
 #include "ctdb_client.h"
 
@@ -1206,7 +1206,7 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
 
        ctdb->ctdbd_pid = getpid();
        DEBUG(DEBUG_ERR, ("Starting CTDBD (Version %s) as PID: %u\n",
-                         CTDB_VERSION_STRING, ctdb->ctdbd_pid));
+                         ctdb_version_string, ctdb->ctdbd_pid));
        ctdb_create_pidfile(ctdb);
 
        /* create a unix domain stream socket to listen to */
index f8f9a18fa7e2d65e197ebbb4c0f7f931d16ecc32..a135da2a8b82d20bdf0b60aae7529de21657fbc8 100644 (file)
@@ -30,7 +30,7 @@
 #include <tevent.h>
 #include <tdb.h>
 
-#include "ctdb_version.h"
+#include "common/version.h"
 #include "lib/util/debug.h"
 #include "lib/util/samba_util.h"
 #include "lib/util/sys_rw.h"
@@ -725,7 +725,7 @@ static int run_helper(TALLOC_CTX *mem_ctx, const char *command,
 static int control_version(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
                           int argc, const char **argv)
 {
-       printf("%s\n", CTDB_VERSION_STRING);
+       printf("%s\n", ctdb_version_string);
        return 0;
 }
 
index 2679c56db3064a5c4ae1ef5cebfce280483194bd..0523bde5449f7ec1d31fabe1a2653f486ce2e2ba 100644 (file)
@@ -386,7 +386,7 @@ def build(bld):
                                              logging.c rb_tree.c tunable.c
                                              pidfile.c run_proc.c
                                              hash_count.c run_event.c
-                                             sock_client.c'''),
+                                             sock_client.c version.c'''),
                         deps='''samba-util sys_rw tevent-util
                                 replace talloc tevent tdb''')