changeset 4131:073121aafb67

8014431: cleanup warnings indicated by the -Wunused-value compiler option on linux 8015265: revise the fix for 8007037 Reviewed-by: sspitsyn, dholmes, dcubed, coleenp Contributed-by: jeremymanson@google.com, calvin.cheung@oracle.com
author ccheung
date Tue, 15 Nov 2016 03:00:02 +0000
parents 1a9842caf835
children ecd56b400ef3
files src/cpu/x86/vm/stubGenerator_x86_32.cpp src/cpu/x86/vm/stubGenerator_x86_64.cpp src/share/vm/c1/c1_IR.cpp src/share/vm/ci/ciUtilities.hpp src/share/vm/classfile/verifier.hpp src/share/vm/code/dependencies.cpp src/share/vm/code/nmethod.cpp src/share/vm/memory/cardTableModRefBS.cpp src/share/vm/memory/universe.cpp src/share/vm/opto/memnode.cpp src/share/vm/prims/forte.cpp src/share/vm/runtime/sharedRuntime.cpp src/share/vm/services/diagnosticArgument.cpp src/share/vm/utilities/exceptions.hpp src/share/vm/utilities/taskqueue.hpp
diffstat 15 files changed, 49 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Mon Nov 14 06:40:12 2016 +0000
+++ b/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Tue Nov 15 03:00:02 2016 +0000
@@ -94,7 +94,7 @@
  private:
 
 #ifdef PRODUCT
-#define inc_counter_np(counter) (0)
+#define inc_counter_np(counter) ((void)0)
 #else
   void inc_counter_np_(int& counter) {
     __ incrementl(ExternalAddress((address)&counter));
--- a/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Mon Nov 14 06:40:12 2016 +0000
+++ b/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Tue Nov 15 03:00:02 2016 +0000
@@ -92,7 +92,7 @@
  private:
 
 #ifdef PRODUCT
-#define inc_counter_np(counter) (0)
+#define inc_counter_np(counter) ((void)0)
 #else
   void inc_counter_np_(int& counter) {
     // This can destroy rscratch1 if counter is far from the code cache
--- a/src/share/vm/c1/c1_IR.cpp	Mon Nov 14 06:40:12 2016 +0000
+++ b/src/share/vm/c1/c1_IR.cpp	Tue Nov 15 03:00:02 2016 +0000
@@ -499,7 +499,7 @@
   _loop_map(0, 0),          // initialized later with correct size
   _compilation(c)
 {
-  TRACE_LINEAR_SCAN(2, "***** computing linear-scan block order");
+  TRACE_LINEAR_SCAN(2, tty->print_cr("***** computing linear-scan block order"));
 
   init_visited();
   count_edges(start_block, NULL);
@@ -665,7 +665,7 @@
 }
 
 void ComputeLinearScanOrder::assign_loop_depth(BlockBegin* start_block) {
-  TRACE_LINEAR_SCAN(3, "----- computing loop-depth and weight");
+  TRACE_LINEAR_SCAN(3, tty->print_cr("----- computing loop-depth and weight"));
   init_visited();
 
   assert(_work_list.is_empty(), "work list must be empty before processing");
@@ -839,7 +839,7 @@
 }
 
 void ComputeLinearScanOrder::compute_order(BlockBegin* start_block) {
-  TRACE_LINEAR_SCAN(3, "----- computing final block order");
+  TRACE_LINEAR_SCAN(3, tty->print_cr("----- computing final block order"));
 
   // the start block is always the first block in the linear scan order
   _linear_scan_order = new BlockList(_num_blocks);
--- a/src/share/vm/ci/ciUtilities.hpp	Mon Nov 14 06:40:12 2016 +0000
+++ b/src/share/vm/ci/ciUtilities.hpp	Tue Nov 15 03:00:02 2016 +0000
@@ -93,7 +93,7 @@
     CLEAR_PENDING_EXCEPTION;                     \
     return (result);                             \
   }                                              \
-  (0
+  (void)(0
 
 #define KILL_COMPILE_ON_ANY                      \
   THREAD);                                       \
@@ -101,7 +101,7 @@
     fatal("unhandled ci exception");             \
     CLEAR_PENDING_EXCEPTION;                     \
   }                                              \
-(0
+(void)(0
 
 
 inline const char* bool_to_str(bool b) {
--- a/src/share/vm/classfile/verifier.hpp	Mon Nov 14 06:40:12 2016 +0000
+++ b/src/share/vm/classfile/verifier.hpp	Tue Nov 15 03:00:02 2016 +0000
@@ -85,9 +85,9 @@
 // These macros are used similarly to CHECK macros but also check
 // the status of the verifier and return if that has an error.
 #define CHECK_VERIFY(verifier) \
-  CHECK); if ((verifier)->has_error()) return; (0
+  CHECK); if ((verifier)->has_error()) return; ((void)0
 #define CHECK_VERIFY_(verifier, result) \
-  CHECK_(result)); if ((verifier)->has_error()) return (result); (0
+  CHECK_(result)); if ((verifier)->has_error()) return (result); ((void)0
 
 // A new instance of this class is created for each class being verified
 class ClassVerifier : public StackObj {
--- a/src/share/vm/code/dependencies.cpp	Mon Nov 14 06:40:12 2016 +0000
+++ b/src/share/vm/code/dependencies.cpp	Tue Nov 15 03:00:02 2016 +0000
@@ -932,7 +932,7 @@
   assert(changes.involves_context(context_type), "irrelevant dependency");
   klassOop new_type = changes.new_type();
 
-  count_find_witness_calls();
+  (void)count_find_witness_calls();
   NOT_PRODUCT(deps_find_witness_singles++);
 
   // Current thread must be in VM (not native mode, as in CI):
--- a/src/share/vm/code/nmethod.cpp	Mon Nov 14 06:40:12 2016 +0000
+++ b/src/share/vm/code/nmethod.cpp	Tue Nov 15 03:00:02 2016 +0000
@@ -2488,7 +2488,8 @@
                       relocation_begin()-1+ip[1]);
       for (; ip < index_end; ip++)
         tty->print_cr("  (%d ?)", ip[0]);
-      tty->print_cr("          @" INTPTR_FORMAT ": index_size=%d", ip, *ip++);
+      tty->print_cr("          @" INTPTR_FORMAT ": index_size=%d", ip, *ip);
+      ip++;
       tty->print_cr("reloc_end @" INTPTR_FORMAT ":", ip);
     }
   }
--- a/src/share/vm/memory/cardTableModRefBS.cpp	Mon Nov 14 06:40:12 2016 +0000
+++ b/src/share/vm/memory/cardTableModRefBS.cpp	Tue Nov 15 03:00:02 2016 +0000
@@ -389,7 +389,7 @@
   }
   // Touch the last card of the covered region to show that it
   // is committed (or SEGV).
-  debug_only(*byte_for(_covered[ind].last());)
+  debug_only((void) (*byte_for(_covered[ind].last()));)
   debug_only(verify_guard();)
 }
 
--- a/src/share/vm/memory/universe.cpp	Mon Nov 14 06:40:12 2016 +0000
+++ b/src/share/vm/memory/universe.cpp	Tue Nov 15 03:00:02 2016 +0000
@@ -657,7 +657,9 @@
   if (vt) vt->initialize_vtable(false, CHECK);
   if (ko->oop_is_instance()) {
     instanceKlass* ik = (instanceKlass*)ko;
-    for (KlassHandle s_h(THREAD, ik->subklass()); s_h() != NULL; s_h = (THREAD, s_h()->klass_part()->next_sibling())) {
+    for (KlassHandle s_h(THREAD, ik->subklass());
+         s_h() != NULL;
+         s_h = (THREAD, s_h()->klass_part()->next_sibling())) {
       reinitialize_vtable_of(s_h, CHECK);
     }
   }
--- a/src/share/vm/opto/memnode.cpp	Mon Nov 14 06:40:12 2016 +0000
+++ b/src/share/vm/opto/memnode.cpp	Tue Nov 15 03:00:02 2016 +0000
@@ -4163,7 +4163,7 @@
   }
 }
 #else // !ASSERT
-#define verify_memory_slice(m,i,n) (0)  // PRODUCT version is no-op
+#define verify_memory_slice(m,i,n) (void)(0)  // PRODUCT version is no-op
 #endif
 
 
--- a/src/share/vm/prims/forte.cpp	Mon Nov 14 06:40:12 2016 +0000
+++ b/src/share/vm/prims/forte.cpp	Tue Nov 15 03:00:02 2016 +0000
@@ -635,7 +635,7 @@
                             void* null_argument_3);
 #pragma weak collector_func_load
 #define collector_func_load(x0,x1,x2,x3,x4,x5,x6) \
-        ( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),0 : 0 )
+        ( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),(void)0 : (void)0 )
 #endif // __APPLE__
 #endif // !_WINDOWS
 
--- a/src/share/vm/runtime/sharedRuntime.cpp	Mon Nov 14 06:40:12 2016 +0000
+++ b/src/share/vm/runtime/sharedRuntime.cpp	Tue Nov 15 03:00:02 2016 +0000
@@ -2778,7 +2778,7 @@
   // ResourceObject, so do not put any ResourceMarks in here.
   char *s = sig->as_C_string();
   int len = (int)strlen(s);
-  *s++; len--;                  // Skip opening paren
+  s++; len--;                   // Skip opening paren
   char *t = s+len;
   while( *(--t) != ')' ) ;      // Find close paren
 
--- a/src/share/vm/services/diagnosticArgument.cpp	Mon Nov 14 06:40:12 2016 +0000
+++ b/src/share/vm/services/diagnosticArgument.cpp	Tue Nov 15 03:00:02 2016 +0000
@@ -191,7 +191,7 @@
   } else {
     _value._time = 0;
     _value._nanotime = 0;
-    strcmp(_value._unit, "ns");
+    strcpy(_value._unit, "ns");
   }
 }
 
--- a/src/share/vm/utilities/exceptions.hpp	Mon Nov 14 06:40:12 2016 +0000
+++ b/src/share/vm/utilities/exceptions.hpp	Tue Nov 15 03:00:02 2016 +0000
@@ -182,15 +182,15 @@
 #define HAS_PENDING_EXCEPTION                    (((ThreadShadow*)THREAD)->has_pending_exception())
 #define CLEAR_PENDING_EXCEPTION                  (((ThreadShadow*)THREAD)->clear_pending_exception())
 
-#define CHECK                                    THREAD); if (HAS_PENDING_EXCEPTION) return       ; (0
-#define CHECK_(result)                           THREAD); if (HAS_PENDING_EXCEPTION) return result; (0
+#define CHECK                                    THREAD); if (HAS_PENDING_EXCEPTION) return       ; (void)(0
+#define CHECK_(result)                           THREAD); if (HAS_PENDING_EXCEPTION) return result; (void)(0
 #define CHECK_0                                  CHECK_(0)
 #define CHECK_NH                                 CHECK_(Handle())
 #define CHECK_NULL                               CHECK_(NULL)
 #define CHECK_false                              CHECK_(false)
 
-#define CHECK_AND_CLEAR                         THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return;        } (0
-#define CHECK_AND_CLEAR_(result)                THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return result; } (0
+#define CHECK_AND_CLEAR                         THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return;        } (void)(0
+#define CHECK_AND_CLEAR_(result)                THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return result; } (void)(0
 #define CHECK_AND_CLEAR_0                       CHECK_AND_CLEAR_(0)
 #define CHECK_AND_CLEAR_NH                      CHECK_AND_CLEAR_(Handle())
 #define CHECK_AND_CLEAR_NULL                    CHECK_AND_CLEAR_(NULL)
@@ -263,7 +263,7 @@
     CLEAR_PENDING_EXCEPTION;               \
     ex->print();                           \
     ShouldNotReachHere();                  \
-  } (0
+  } (void)(0
 
 // ExceptionMark is a stack-allocated helper class for local exception handling.
 // It is used with the EXCEPTION_MARK macro.
--- a/src/share/vm/utilities/taskqueue.hpp	Mon Nov 14 06:40:12 2016 +0000
+++ b/src/share/vm/utilities/taskqueue.hpp	Tue Nov 15 03:00:02 2016 +0000
@@ -334,8 +334,12 @@
   if (dirty_n_elems == N - 1) {
     // Actually means 0, so do the push.
     uint localBot = _bottom;
-    // g++ complains if the volatile result of the assignment is unused.
-    const_cast<E&>(_elems[localBot] = t);
+    // g++ complains if the volatile result of the assignment is
+    // unused, so we cast the volatile away.  We cannot cast directly
+    // to void, because gcc treats that as not using the result of the
+    // assignment.  However, casting to E& means that we trigger an
+    // unused-value warning.  So, we cast the E& to void.
+    (void)const_cast<E&>(_elems[localBot] = t);
     OrderAccess::release_store(&_bottom, increment_index(localBot));
     TASKQUEUE_STATS_ONLY(stats.record_push());
     return true;
@@ -391,7 +395,12 @@
     return false;
   }
 
-  const_cast<E&>(t = _elems[oldAge.top()]);
+  // g++ complains if the volatile result of the assignment is
+  // unused, so we cast the volatile away.  We cannot cast directly
+  // to void, because gcc treats that as not using the result of the
+  // assignment.  However, casting to E& means that we trigger an
+  // unused-value warning.  So, we cast the E& to void.
+  (void) const_cast<E&>(t = _elems[oldAge.top()]);
   Age newAge(oldAge);
   newAge.increment();
   Age resAge = _age.cmpxchg(newAge, oldAge);
@@ -673,8 +682,12 @@
   uint dirty_n_elems = dirty_size(localBot, top);
   assert(dirty_n_elems < N, "n_elems out of range.");
   if (dirty_n_elems < max_elems()) {
-    // g++ complains if the volatile result of the assignment is unused.
-    const_cast<E&>(_elems[localBot] = t);
+    // g++ complains if the volatile result of the assignment is
+    // unused, so we cast the volatile away.  We cannot cast directly
+    // to void, because gcc treats that as not using the result of the
+    // assignment.  However, casting to E& means that we trigger an
+    // unused-value warning.  So, we cast the E& to void.
+    (void) const_cast<E&>(_elems[localBot] = t);
     OrderAccess::release_store(&_bottom, increment_index(localBot));
     TASKQUEUE_STATS_ONLY(stats.record_push());
     return true;
@@ -698,7 +711,12 @@
   // This is necessary to prevent any read below from being reordered
   // before the store just above.
   OrderAccess::fence();
-  const_cast<E&>(t = _elems[localBot]);
+  // g++ complains if the volatile result of the assignment is
+  // unused, so we cast the volatile away.  We cannot cast directly
+  // to void, because gcc treats that as not using the result of the
+  // assignment.  However, casting to E& means that we trigger an
+  // unused-value warning.  So, we cast the E& to void.
+  (void) const_cast<E&>(t = _elems[localBot]);
   // This is a second read of "age"; the "size()" above is the first.
   // If there's still at least one element in the queue, based on the
   // "_bottom" and "age" we've read, then there can be no interference with