profiling: Only compile profile/profile.c if profiling is enabled
authorVolker Lendecke <vl@samba.org>
Tue, 30 Sep 2014 15:08:20 +0000 (15:08 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 3 Oct 2014 17:55:09 +0000 (19:55 +0200)
This conditional compile avoids some #ifdef WITH_PROFILE, which makes the code
more readable

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/profile/profile.c
source3/profile/profile_dummy.c [new file with mode: 0644]
source3/wscript_build

index 9ef2c69ff6e7ed04575beaa0ffbe04f862b8a00e..9367ff45fa94db0acb60267cfa4fe6c92f119f82 100644 (file)
 #define PROF_SHM_MAGIC 0x6349985
 #define PROF_SHM_VERSION 13
 
-#ifdef WITH_PROFILE
 #define IPC_PERMS ((S_IRUSR | S_IWUSR) | S_IRGRP | S_IROTH)
-#endif /* WITH_PROFILE */
 
-#ifdef WITH_PROFILE
 static int shm_id;
 static bool read_only;
-#endif
 
 struct profile_header {
        int prof_shm_magic;
@@ -55,7 +51,6 @@ Set a profiling level.
 ****************************************************************************/
 void set_profile_level(int level, struct server_id src)
 {
-#ifdef WITH_PROFILE
        switch (level) {
        case 0:         /* turn off profiling */
                do_profile_flag = False;
@@ -81,13 +76,8 @@ void set_profile_level(int level, struct server_id src)
                         (int)procid_to_pid(&src)));
                break;
        }
-#else /* WITH_PROFILE */
-       DEBUG(1,("INFO: Profiling support unavailable in this build.\n"));
-#endif /* WITH_PROFILE */
 }
 
-#ifdef WITH_PROFILE
-
 /****************************************************************************
 receive a set profile level message
 ****************************************************************************/
@@ -119,11 +109,8 @@ static void reqprofile_message(struct messaging_context *msg_ctx,
 {
         int level;
 
-#ifdef WITH_PROFILE
        level = 1 + (do_profile_flag?2:0) + (do_profile_times?4:0);
-#else
-       level = 0;
-#endif
+
        DEBUG(1,("INFO: Received REQ_PROFILELEVEL message from PID %u\n",
                 (unsigned int)procid_to_pid(&src)));
        messaging_send_buf(msg_ctx, src, MSG_PROFILELEVEL,
@@ -413,5 +400,3 @@ bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
        SMB_ASSERT(val < PR_VALUE_MAX);
        return valnames[val];
 }
-
-#endif /* WITH_PROFILE */
diff --git a/source3/profile/profile_dummy.c b/source3/profile/profile_dummy.c
new file mode 100644 (file)
index 0000000..1f820ec
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * profile.c implementation if profiles are not enabled
+ * Copyright (C) Volker Lendecke 2014
+ *
+ * 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 "includes.h"
+#include "smbprofile.h"
+
+bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
+{
+       return true;
+}
+
+void set_profile_level(int level, struct server_id src)
+{
+       DEBUG(1,("INFO: Profiling support unavailable in this build.\n"));
+}
index d3979e8f911018f9d44ce28317dd6b15f0511d0f..54ba3a74888c4e984504e73401bf63cc32640d4e 100755 (executable)
@@ -638,9 +638,14 @@ bld.SAMBA3_SUBSYSTEM('LOCKING',
                     NDR_OPEN_FILES
                     FNAME_UTIL''')
 
-bld.SAMBA3_SUBSYSTEM('PROFILE',
-                    source='profile/profile.c',
-                    deps='samba-util')
+if bld.CONFIG_GET("WITH_PROFILE"):
+    bld.SAMBA3_SUBSYSTEM('PROFILE',
+                         source='profile/profile.c',
+                         deps='samba-util')
+else:
+    bld.SAMBA3_SUBSYSTEM('PROFILE',
+                         source='profile/profile_dummy.c',
+                         deps='')
 
 bld.SAMBA3_SUBSYSTEM('PRINTBASE',
                     source='''printing/notify.c printing/printing_db.c''',