Skip to content

JDK-8301479: Replace NULL with nullptr in os/linux #12315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

jdksjolen
Copy link
Contributor

@jdksjolen jdksjolen commented Jan 31, 2023

Hi, this PR changes all occurrences of NULL to nullptr for the subdirectory os/linux. Unfortunately the script that does the change isn't perfect, and so we
need to comb through these manually to make sure nothing has gone wrong. I also review these changes but things slip past my eyes sometimes.

Here are some typical things to look out for:

  1. No changes but copyright header changed (probably because I reverted some changes but forgot the copyright).
  2. Macros having their NULL changed to nullptr, these are added to the script when I find them. They should be NULL.
  3. nullptr in comments and logs. We try to use lower case "null" in these cases as it reads better. An exception is made when code expressions are in a comment.

An example of this:

// This function returns null
void* ret_null();
// This function returns true if *x == nullptr
bool is_nullptr(void** x);

Note how nullptr participates in a code expression here, we really are talking about the specific value nullptr.

Thanks!


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12315/head:pull/12315
$ git checkout pull/12315

Update a local copy of the PR:
$ git checkout pull/12315
$ git pull https://git.openjdk.org/jdk pull/12315/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 12315

View PR using the GUI difftool:
$ git pr show -t 12315

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12315.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 31, 2023

👋 Welcome back jsjolen! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jan 31, 2023

@jdksjolen The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Jan 31, 2023
Copy link
Contributor Author

@jdksjolen jdksjolen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found some things to fix

@@ -166,7 +166,7 @@ PRAGMA_DIAG_POP
int err; \
err = subsystem_file_line_contents(subsystem, \
filename, \
NULL, \
nullptr, \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align

@@ -184,11 +184,11 @@ PRAGMA_DIAG_POP
int err; \
err = subsystem_file_line_contents(subsystem, \
filename, \
NULL, \
nullptr, \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align

scan_fmt, \
variable); \
if (err != 0) \
return (return_type) NULL; \
return (return_type) nullptr; \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align

Comment on lines 2169 to 2177
const char *p_ct = OSContainer::container_type();
st->print_cr("container_type: %s", p_ct != NULL ? p_ct : "not supported");
st->print_cr("container_type: %s", p_ct != null ? p_ct : "not supported");

char *p = OSContainer::cpu_cpuset_cpus();
st->print_cr("cpu_cpuset_cpus: %s", p != NULL ? p : "not supported");
st->print_cr("cpu_cpuset_cpus: %s", p != null ? p : "not supported");
free(p);

p = OSContainer::cpu_cpuset_memory_nodes();
st->print_cr("cpu_memory_nodes: %s", p != NULL ? p : "not supported");
st->print_cr("cpu_memory_nodes: %s", p != null ? p : "not supported");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glitched out

}

// Allocate (using mmap, NO_RESERVE, with small pages) at either a given request address
// (req_addr != NULL) or with a given alignment.
// (req_addr != null) or with a given alignment.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullptr

assert(is_aligned(req_addr, os::large_page_size()), "Must be divisible by the large page size");
assert(is_aligned(req_addr, alignment), "Must be divisible by given alignment");
return shmat_at_address(shmid, req_addr);
}

// Since shmid has been setup with SHM_HUGETLB, shmat will automatically
// return large page size aligned memory addresses when req_addr == NULL.
// return large page size aligned memory addresses when req_addr == null.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullptr

@jdksjolen jdksjolen marked this pull request as ready for review January 31, 2023 10:37
@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 31, 2023
@mlbridge
Copy link

mlbridge bot commented Jan 31, 2023

Webrevs

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks trivial.

@openjdk
Copy link

openjdk bot commented Jan 31, 2023

@jdksjolen This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8301479: Replace NULL with nullptr in os/linux

Reviewed-by: coleenp, sgehwolf

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 111 new commits pushed to the master branch:

  • 2d50c7d: 8298979: Remove duplicated serviceability/jvmti/thread/GetAllThreads/allthr01/allthr01.java
  • 59b7fb1: 8300273: [IR framework] Handle message instead of bailing out
  • 5b1584b: 8298880: VectorLogicalOpIdentityTest.java IR test incorrectly use avx3 instead of avx512
  • 21c1afb: 8301612: OopLoadProxy constructor should be explicit
  • 03b23a1: 8301367: Add exception handler method to the BaseLdapServer
  • 7b6ac41: 8286876: NMT.test_unaliged_block_address_vm_assert fails if using clang toolchain
  • d097b5e: 8301508: Replace NULL with nullptr in os_cpu/linux_s390
  • c8307e3: 8301500: Replace NULL with nullptr in os_cpu/aix_ppc
  • 218223e: 8301501: Replace NULL with nullptr in os_cpu/bsd_aarch64
  • b81f0ff: 8301505: Replace NULL with nullptr in os_cpu/linux_arm
  • ... and 101 more: https://git.openjdk.org/jdk/compare/107e184d59c0bbed6441a3c1a9bfd4527da3bce5...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 31, 2023
Copy link
Contributor

@jerboaa jerboaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me.

@jdksjolen
Copy link
Contributor Author

All tests passing, integrating. Thanks for review.

/integrate

@openjdk
Copy link

openjdk bot commented Feb 3, 2023

Going to push as commit ac9e046.
Since your change was applied there have been 127 commits pushed to the master branch:

  • cf68d9f: 8299155: C2: SubTypeCheckNode::verify() should not produce dependencies / oop pool entries
  • 11804b2: 8301050: Detect Xen Virtualization on Linux aarch64
  • b504c94: 8300235: Use VarHandle access in Image(Input | Output)StreamImpl classes
  • 406021a: 8300929: Avoid unnecessary array fill after creation in java.awt.image
  • 7f313b0: 8180266: Convert sun/security/provider/KeyStore/DKSTest.sh to Java Jtreg Test
  • 3ad6aef: 8301313: RISC-V: C2: assert(false) failed: bad AD file due to missing match rule
  • 4c9de87: 8301655: Problemlist jdk/jdk/nio/zipfs/TestLocOffsetFromZip64EF.java on Linux
  • 04278e6: 8301564: Non-C-heap allocated ResourceHashtable keys and values must have trivial destructor
  • b00b70c: 8286907: keytool should warn about weak PBE algorithms
  • ee0f5b5: 8301392: Port fdlibm log1p to Java
  • ... and 117 more: https://git.openjdk.org/jdk/compare/107e184d59c0bbed6441a3c1a9bfd4527da3bce5...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Feb 3, 2023
@openjdk openjdk bot closed this Feb 3, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Feb 3, 2023
@openjdk
Copy link

openjdk bot commented Feb 3, 2023

@jdksjolen Pushed as commit ac9e046.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants