RFR: 8263446: Avoid unary minus over unsigned type in ObjectSynchronizer::dec_in_use_list_ceiling
Andrew Haley
aph at openjdk.java.net
Thu Mar 11 13:20:25 UTC 2021
On Thu, 11 Mar 2021 13:14:01 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> SonarCloud complains:
> Unary minus should not be applied to an unsigned expression
>
> Here:
>
> void ObjectSynchronizer::dec_in_use_list_ceiling() {
> Atomic::add(&_in_use_list_ceiling, -AvgMonitorsPerThreadEstimate);
> }
>
> We can instead use `Atomic::sub`.
>
> Additional testing:
> - [x] Linux x86_64 fastdebug `hotspot:tier1`
Surely SonarCloud is simply wrong about this. Unary minus on unsigned is well-defined in C and C++.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2939
More information about the hotspot-runtime-dev
mailing list