s3: make better use of ccache by not including version.h in every C-file.
authorMichael Adam <obnox@samba.org>
Thu, 15 Jan 2009 21:27:52 +0000 (22:27 +0100)
committerMichael Adam <obnox@samba.org>
Thu, 15 Jan 2009 21:56:01 +0000 (22:56 +0100)
version.h changes rather frequently. Since it is included via includes.h,
this means each C file will be a cache miss. This applies to the following
situations:

* When building a new package with a new Samba version

* building in a git branch after calling mkversion.sh
  after a new commit (i.e. virtually always)

This patch improves the situation in the following way:

* remove inlude "version.h" from includes.h

* Use samba_version_string() instead of SAMBA_VERSION_STRING
  in files that use no other macro from version.h instead of
  SAMBA_VERSION_STRING.

* explicitly include "version.h" in those files that use more
  macros from "version.h" than just SAMBA_VERSION_STRING.

Michael

18 files changed:
source3/client/client.c
source3/include/includes.h
source3/lib/fault.c
source3/lib/popt_common.c
source3/lib/substitute.c
source3/lib/version.c
source3/libnet/libnet_join.c
source3/libsmb/cliconnect.c
source3/libsmb/libsmb_context.c
source3/nmbd/nmbd.c
source3/param/loadparm.c
source3/smbd/server.c
source3/smbd/sesssetup.c
source3/smbd/trans2.c
source3/utils/status.c
source3/web/statuspage.c
source3/winbindd/winbindd.c
source3/winbindd/winbindd_misc.c

index 7172bf98a954ddd80f2f0ebf2bfd5d70fca6919a..2f9e3c0d49716299ea5b5f46c5339601309d188d 100644 (file)
@@ -4974,7 +4974,7 @@ static int do_message_op(struct user_auth_info *auth_info)
 
        cli_cm_set_credentials(auth_info);
 
-       DEBUG(3,("Client started (version %s).\n", SAMBA_VERSION_STRING));
+       DEBUG(3,("Client started (version %s).\n", samba_version_string()));
 
        if (tar_type) {
                if (cmdstr)
index 10d37eefd9523955360eb899389d61878e97730d..63b567d419d6e25f5aa2056f38d4b5d38153dd7f 100644 (file)
@@ -594,7 +594,6 @@ struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx);
 #include "dynconfig.h"
 #include "util_getent.h"
 #include "debugparse.h"
-#include "version.h"
 #include "privileges.h"
 #include "messages.h"
 #include "locking.h"
index c24fea1ca91267b7156699fbd38cbaf3a0eac13e..a1530987f3b1ea4c4309d6a347a0a27f4c51a0a0 100644 (file)
@@ -38,7 +38,7 @@ static void fault_report(int sig)
        counter++;
 
        DEBUGSEP(0);
-       DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),SAMBA_VERSION_STRING));
+       DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),samba_version_string()));
        DEBUG(0,("\nPlease read the Trouble-Shooting section of the Samba3-HOWTO\n"));
        DEBUG(0,("\nFrom: http://www.samba.org/samba/docs/Samba3-HOWTO.pdf\n"));
        DEBUGSEP(0);
index 115133089c73911c6a1fcfaeed3db0cba4f080d3..e14477c9799b31c036ec4f81971fd9a9972d6f4a 100644 (file)
@@ -73,7 +73,7 @@ static void popt_common_callback(poptContext con,
        if (reason == POPT_CALLBACK_REASON_POST) {
 
                if (PrintSambaVersionString) {
-                       printf( "Version %s\n", SAMBA_VERSION_STRING);
+                       printf( "Version %s\n", samba_version_string());
                        exit(0);
                }
 
index acfe55d7617d6499c461b65a476f2aa562524203..b4f5f70fa05cd2b17d967c4b106a8241419d384d 100644 (file)
@@ -659,7 +659,7 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
                                                      : "");
                        break;
                case 'v' :
-                       a_string = realloc_string_sub(a_string, "%v", SAMBA_VERSION_STRING);
+                       a_string = realloc_string_sub(a_string, "%v", samba_version_string());
                        break;
                case 'w' :
                        a_string = realloc_string_sub(a_string, "%w", lp_winbind_separator());
index 55fb53c5db70623e5f7e2195cbac8752547afc75..e81f463586e296382be26b440c3fd8c7d35d6fc8 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 #include "includes.h"
-#include <assert.h>
+#include "version.h"
 
 const char *samba_version_string(void)
 {
index 18743aad55210bd1fbddf84bde0d77f2fab48e88..be6943bad97159fdc10485123fdc51585b732428 100644 (file)
@@ -470,7 +470,7 @@ static ADS_STATUS libnet_join_set_os_attributes(TALLOC_CTX *mem_ctx,
                return ADS_ERROR(LDAP_NO_MEMORY);
        }
 
-       os_sp = talloc_asprintf(mem_ctx, "Samba %s", SAMBA_VERSION_STRING);
+       os_sp = talloc_asprintf(mem_ctx, "Samba %s", samba_version_string());
        if (!os_sp) {
                return ADS_ERROR(LDAP_NO_MEMORY);
        }
index b446879140e24c895e05ef94e465c932f2a33d43..9e4266de5a5e27577a56650612416acb9bcb2025 100644 (file)
@@ -224,7 +224,7 @@ static NTSTATUS cli_session_setup_plaintext(struct cli_state *cli,
        char *p;
        fstring lanman;
        
-       fstr_sprintf( lanman, "Samba %s", SAMBA_VERSION_STRING);
+       fstr_sprintf( lanman, "Samba %s", samba_version_string());
 
        memset(cli->outbuf, '\0', smb_size);
        cli_set_message(cli->outbuf,13,0,True);
index becee17f655658e714ea4d764871bb0ec19e2f3e..66329e286053f72a465bf719bff08daf29a0a812 100644 (file)
@@ -619,7 +619,7 @@ smbc_init_context(SMBCCTX *context)
 const char *
 smbc_version(void)
 {
-        return SAMBA_VERSION_STRING;
+        return samba_version_string();
 }
 
 
index 659db85e69f480da035444f952a7da387ec86b7b..10d6fe237828489e69161a301ee954dee5b65ac2 100644 (file)
@@ -847,7 +847,7 @@ static bool open_sockets(bool isdaemon, int port)
 
        reopen_logs();
 
-       DEBUG(0,("nmbd version %s started.\n", SAMBA_VERSION_STRING));
+       DEBUG(0,("nmbd version %s started.\n", samba_version_string()));
        DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE));
 
        if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
index a874ce29d853847b80789ffc908d35ac05d1594a..6438888942fe5fb474c1bce88cbcb04b19df2cc7 100644 (file)
@@ -4773,7 +4773,7 @@ static void init_globals(bool first_time_only)
        string_set(&Globals.szPidDir, get_dyn_PIDDIR());
        string_set(&Globals.szSocketAddress, "0.0.0.0");
 
-       if (asprintf(&s, "Samba %s", SAMBA_VERSION_STRING) < 0) {
+       if (asprintf(&s, "Samba %s", samba_version_string()) < 0) {
                smb_panic("init_globals: ENOMEM");
        }
        string_set(&Globals.szServerString, s);
index 6be8e9b83e7ed3aae2be574db5ae45b9440b9f23..00e939e2b802888b0850465add493a58f027c5fd 100644 (file)
@@ -1231,7 +1231,7 @@ extern void build_options(bool screen);
 
        reopen_logs();
 
-       DEBUG(0,("smbd version %s started.\n", SAMBA_VERSION_STRING));
+       DEBUG(0,("smbd version %s started.\n", samba_version_string()));
        DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE));
 
        DEBUG(2,("uid=%d gid=%d euid=%d egid=%d\n",
index b8e0c86833e7e65fb01665be54402c4fe42d31d9..a2ad56bea16f94495840ca032cb13b4a9c646dfd 100644 (file)
@@ -71,7 +71,7 @@ static int push_signature(uint8 **outbuf)
        if (tmp == -1) return -1;
        result += tmp;
 
-       if (asprintf(&lanman, "Samba %s", SAMBA_VERSION_STRING) != -1) {
+       if (asprintf(&lanman, "Samba %s", samba_version_string()) != -1) {
                tmp = message_push_string(outbuf, lanman, STR_TERMINATE);
                SAFE_FREE(lanman);
        }
index 9644e3d1ad0d38d744d07a8f3ac2bcb1633d0b76..52340d53703873135d462993bfa4b7d5c4a51eed 100644 (file)
@@ -24,6 +24,7 @@
 */
 
 #include "includes.h"
+#include "version.h"
 #include "smbd/globals.h"
 
 extern enum protocol_types Protocol;
index 1a66af949a1830135f2657ca6789d65c745894ba..590444a42f6d42a9d2f3b0be0d6394464cd1657c 100644 (file)
@@ -406,7 +406,7 @@ static int traverse_sessionid(struct db_record *db, void *state)
                if (!db) {
                        d_printf("sessionid.tdb not initialised\n");
                } else {
-                       d_printf("\nSamba version %s\n",SAMBA_VERSION_STRING);
+                       d_printf("\nSamba version %s\n",samba_version_string());
                        d_printf("PID     Username      Group         Machine                        \n");
                        d_printf("-------------------------------------------------------------------\n");
 
index e684a075c25228762bdccf994dfdebdca84a32b1..cb8485a6ebb3afc98a6104fbcc17af9af2272818 100644 (file)
@@ -345,7 +345,7 @@ void status_page(void)
 
        printf("<table>\n");
 
-       printf("<tr><td>%s</td><td>%s</td></tr>", _("version:"), SAMBA_VERSION_STRING);
+       printf("<tr><td>%s</td><td>%s</td></tr>", _("version:"), samba_version_string());
 
        fflush(stdout);
        printf("<tr><td>%s</td><td>%s</td>\n", _("smbd:"), smbd_running()?_("running"):_("not running"));
index 8f94f8ad70fd3ea3dc8d26288d1111f04b0e9a36..821812925c6d4818f05959dbc46019afe61a8c30 100644 (file)
@@ -1121,7 +1121,7 @@ int main(int argc, char **argv, char **envp)
        setup_logging("winbindd", log_stdout);
        reopen_logs();
 
-       DEBUG(0,("winbindd version %s started.\n", SAMBA_VERSION_STRING));
+       DEBUG(0,("winbindd version %s started.\n", samba_version_string()));
        DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE));
 
        if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
index 0e34615c3a250672e349dd8601fa82578f5132d2..737fd08d2a2221af0b58576f16ad99f96279c8a3 100644 (file)
@@ -742,7 +742,7 @@ void winbindd_info(struct winbindd_cli_state *state)
        DEBUG(3, ("[%5lu]: request misc info\n", (unsigned long)state->pid));
 
        state->response.data.info.winbind_separator = *lp_winbind_separator();
-       fstrcpy(state->response.data.info.samba_version, SAMBA_VERSION_STRING);
+       fstrcpy(state->response.data.info.samba_version, samba_version_string());
        request_ok(state);
 }