]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmds/cosd: Fix IsHeapProfilerRunning implicit return type cast.
authorAlexandre Oliva <oliva@lsd.ic.unicamp.br>
Wed, 2 Mar 2011 21:39:09 +0000 (13:39 -0800)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Wed, 2 Mar 2011 21:39:09 +0000 (13:39 -0800)
G++ complains about the difference between the return type of tcmalloc's
IsHeapProfilerRunning (int) and the return type of the function that
g_conf.profiler_running is supposed to point to (bool). We could
probably get away with a type-cast, but as a compiler developer and
former C++ language lawyer, I'd rather not take the risk of destroying
the universe by invoking undefined behavior ;-)

Signed-off-by: Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/cmds.cc
src/cosd.cc

index c058b51b5a0c6f7b679e0d4c47cd9ed3ebfc4e4b..8d3eb958809ae403cb652e8637be0b99983b373d 100644 (file)
@@ -58,6 +58,13 @@ void usage()
   generic_server_usage();
 }
 
+#ifdef HAVE_LIBTCMALLOC
+/* Adjust the return type */
+static bool isHeapProfilerRunning(void) {
+  return IsHeapProfilerRunning();
+}
+#endif //HAVE_LIBTCMALLOC
+
 int main(int argc, const char **argv) 
 {
   DEFINE_CONF_VARS(usage);
@@ -67,7 +74,7 @@ int main(int argc, const char **argv)
 
 #ifdef HAVE_LIBTCMALLOC
   g_conf.profiler_start = HeapProfilerStart;
-  g_conf.profiler_running = IsHeapProfilerRunning;
+  g_conf.profiler_running = isHeapProfilerRunning;
   g_conf.profiler_stop = HeapProfilerStop;
   g_conf.profiler_dump = HeapProfilerDump;
   g_conf.tcmalloc_have = true;
index edffb329adbad3dba9ed2f6a3292c1a033d842ec..d7a300dd72e54bda5fd34d96a18cd15372d2a96e 100644 (file)
@@ -45,6 +45,12 @@ void usage()
   generic_server_usage();
 }
 
+#ifdef HAVE_LIBTCMALLOC
+/* Adjust the return type */
+static bool isHeapProfilerRunning(void) {
+  return IsHeapProfilerRunning();
+}
+#endif //HAVE_LIBTCMALLOC
 
 int main(int argc, const char **argv) 
 {
@@ -64,7 +70,7 @@ int main(int argc, const char **argv)
 
 #ifdef HAVE_LIBTCMALLOC
   g_conf.profiler_start = HeapProfilerStart;
-  g_conf.profiler_running = IsHeapProfilerRunning;
+  g_conf.profiler_running = isHeapProfilerRunning;
   g_conf.profiler_stop = HeapProfilerStop;
   g_conf.profiler_dump = HeapProfilerDump;
   g_conf.tcmalloc_have = true;