Patchwork [libjava] : Avoid suggest parentheses around comparison in operand of '|' in java/lang/natObject.cc

login
register
mail settings
Submitter Uros Bizjak
Date March 10, 2014, 8:13 p.m.
Message ID <CAFULd4ZNAti1tjKeBDYGePRptfeTCYOyh990cWKw0oTApdUkug@mail.gmail.com>
Download mbox | patch
Permalink /patch/328733/
State New
Headers show

Comments

Uros Bizjak - March 10, 2014, 8:13 p.m.
Hello!

During libjava build, following warning is reported:

../../../gcc-svn/branches/gcc-4_8-branch/libjava/java/lang/natObject.cc:932:27:
warning: suggest parentheses around comparison in operand of '|'
[-Wparentheses]
    JvAssert(he -> address == address | LOCKED );
                           ^

It looks that parentheses are missing around (address | LOCKED),
otherwise the expression is always true - LOCKED is unconditionally
defined to 1. Attached patch adds these parentheses (and removes a
pair of superfluous ones).

2014-03-10  Uros Bizjak  <ubizjak@gmail.com>

    * java/lang/natObject.cc (_Jv_MonitorEnter): Add missing parenthesis
    around comparison with (address | LOCKED) in JvAssert.

Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32}.

OK for mainline SVN and release branches?

Uros.
Andrew Haley - March 11, 2014, 8:52 a.m.
On 03/10/2014 08:13 PM, Uros Bizjak wrote:
> OK for mainline SVN and release branches?

Sure.  You don't need approval for pa

Thanks,
Andrew.
Andrew Haley - March 11, 2014, 8:54 a.m.
On 03/10/2014 08:13 PM, Uros Bizjak wrote:
> OK for mainline SVN and release branches?

Sure.  You don't need approval for patches that are obviously
correct/trivial.

Thanks,
Andrew.

Patch

Index: java/lang/natObject.cc
===================================================================
--- java/lang/natObject.cc	(revision 208455)
+++ java/lang/natObject.cc	(working copy)
@@ -929,7 +929,7 @@  retry:
 	  // only be held by other threads waiting for conversion, and
 	  // they, like us, drop it quickly without blocking.
 	  _Jv_MutexLock(&(hl->si.mutex));
-	  JvAssert(he -> address == address | LOCKED );
+	  JvAssert(he -> address == (address | LOCKED));
 	  release_set(&(he -> address), (address | REQUEST_CONVERSION | HEAVY));
 				// release lock on he
 	  LOG(REQ_CONV, (address | REQUEST_CONVERSION | HEAVY), self);
@@ -961,7 +961,7 @@  retry:
     }
   obj_addr_t was_heavy = (address & HEAVY);
   if ((address & LOCKED) ||
-      !compare_and_swap(&(he -> address), address, (address | LOCKED )))
+      !compare_and_swap(&(he -> address), address, address | LOCKED ))
     {
       wait_unlocked(he);
       goto retry;