vulgatecn / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

[PATCH] Warning cleanup from GCC trunk #534

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This patch cleans up some compiler warning emitted by GCC trunk (4.9 
experimental).

---

Index: src/profiler.cc
===================================================================
--- src/profiler.cc (revision 218)
+++ src/profiler.cc (working copy)
@@ -205,7 +205,7 @@
   if (signal_number_str != NULL)
   {
     long int signal_number = strtol(signal_number_str, NULL, 10);
-   printf("<debug> signal_number=%d\n", signal_number);
+   printf("<debug> signal_number=%ld\n", signal_number);
     if (signal_number >=1 && signal_number <=64)
     {
       sighandler_t old_signal_handler = signal(signal_number, CpuProfilerSwitch);
Index: src/heap-profiler.cc
===================================================================
--- src/heap-profiler.cc    (revision 218)
+++ src/heap-profiler.cc    (working copy)
@@ -293,7 +293,7 @@
     } else if (FLAGS_heap_profile_time_interval > 0 &&
                current_time - last_dump_time >=
                FLAGS_heap_profile_time_interval) {
-      snprintf(buf, sizeof(buf), "%d sec since the last dump",
+      snprintf(buf, sizeof(buf), "%" PRId64 " sec since the last dump",
                current_time - last_dump_time);
       need_to_dump = true;
       last_dump_time = current_time;
Index: src/tests/heap-checker_unittest.cc
===================================================================
--- src/tests/heap-checker_unittest.cc  (revision 218)
+++ src/tests/heap-checker_unittest.cc  (working copy)
@@ -338,7 +338,7 @@
   VLOG(10) << "Wipe level " << n << " at " << &n;
   if (n) {
     const int sz = 30;
-    volatile int arr[sz];
+    volatile int arr[sz] ATTRIBUTE_UNUSED;
     for (int i = 0; i < sz; ++i) arr[i] = 0;
     (*wipe_stack_ptr)(n-1);
     sleep(0);  // undo -foptimize-sibling-calls
@@ -570,7 +570,8 @@
   // the xor trick itself works, as without it nothing in this
   // test suite would work.  See the Hide/Unhide/*Hidden* set
   // of helper methods.
-  CHECK_NE(foo, *reinterpret_cast<void**>(&p));
+  void **pvoid = reinterpret_cast<void**>(&p);
+  CHECK_NE(foo, *pvoid);
 }

 // simple tests that deallocate what they allocated
Index: src/tests/page_heap_test.cc
===================================================================
--- src/tests/page_heap_test.cc (revision 218)
+++ src/tests/page_heap_test.cc (working copy)
@@ -43,7 +43,6 @@

   // Split span 's1' into 's1', 's2'.  Delete 's2'
   tcmalloc::Span* s2 = ph->Split(s1, 128);
-  Length s2_len = s2->length;
   ph->Delete(s2);
   CheckStats(ph, 256, 128, 0);

Index: src/base/basictypes.h
===================================================================
--- src/base/basictypes.h   (revision 218)
+++ src/base/basictypes.h   (working copy)
@@ -185,8 +185,14 @@
 struct CompileAssert {
 };

+#ifdef HAVE___ATTRIBUTE__
+# define ATTRIBUTE_UNUSED __attribute__((unused))
+#else
+# define ATTRIBUTE_UNUSED
+#endif
+
 #define COMPILE_ASSERT(expr, msg)                               \
-  typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
+  typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] ATTRIBUTE_UNUSED

 #define arraysize(a)  (sizeof(a) / sizeof(*(a)))

Original issue reported on code.google.com by zatr...@gmail.com on 28 May 2013 at 1:56

GoogleCodeExporter commented 9 years ago
Looks good. But AFAIR some earlier versions of msvc were not very good at 
stdint and PRId64. I'll have to find some way to check if that works on e.g. 
vs2003 or maybe vs2005

Original comment by alkondratenko on 6 Jul 2013 at 8:51

GoogleCodeExporter commented 9 years ago
actually I'm wrong and gperftools already takes care of those defines

Original comment by alkondratenko on 6 Jul 2013 at 9:29

GoogleCodeExporter commented 9 years ago
applied. Thanks a lot

Original comment by alkondratenko on 6 Jul 2013 at 10:08