JDK-8279533 : Bad indentation and missing curly braces in BlockBegin::set_end
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 18,19
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-01-05
  • Updated: 2022-01-05
  • Resolved: 2022-01-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 19
19 masterFixed
Related Reports
Relates :  
Description
SonarClound reports indentation problem near "if (_end != NULL)". It is also not entirely clear if that block misses `_end = NULL`, like the original code had before JDK-8277496. 

void BlockBegin::set_end(BlockEnd* new_end) { // Assumes that no predecessor of new_end still has it as its successor
  ...
  // Remove this block as predecessor of its current successors
  if (_end != NULL)
  for (int i = 0; i < number_of_sux(); i++) {
    sux_at(i)->remove_predecessor(this);
  }

Ludvig, please take a look?
Comments
Changeset: ab490534 Author: Ludvig Janiuk <ludvig.j.janiuk@oracle.com> Committer: Aleksey Shipilev <shade@openjdk.org> Date: 2022-01-05 20:09:32 +0000 URL: https://git.openjdk.java.net/jdk/commit/ab490534a1d14ad48ceb532ec1673ca9636f552d
05-01-2022

Right, I see how that might have been worrying. To state the obvious, _end = NULL isn't necessary when you're already overwriting it with something.
05-01-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/6972 Date: 2022-01-05 19:33:34 +0000
05-01-2022

> ...but in reality I see this as a false positive. The code should work as intended. Yes, that's good. This is why this one is "Enhancement", not a "Bug". > Please let me know if I misunderstand what you're referring to. Yes, the JDK-8277496 looked as if we inlined `BlockBegin::clear_end` into `BlockBegin::set_end`, dropping `_end = NULL`. Missing indentation and braces made me think that missing `_end = NULL` might have been accidental too.
05-01-2022

I'll fix the brackets and indentation to make it more canonical, but in reality I see this as a false positive. The code should work as intended. > It is also not entirely clear if that block misses `_end = NULL`, like the original code had before JDK-8277496. Before JDK-8277496, BlockBegin::set_end did not have `_end = NULL`. BlockBegin::clear_end did, but that method has been removed. Please let me know if I misunderstand what you're referring to.
05-01-2022

With pleasure.
05-01-2022