RFR: JDK-8301224: Replace NULL with nullptr in share/gc/shared/

Kim Barrett kbarrett at openjdk.org
Sat Jan 28 19:31:25 UTC 2023


On Fri, 27 Jan 2023 10:06:26 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

> Hi, this PR changes all occurrences of NULL to nullptr for the subdirectory share/gc/shared/. 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:
> 
> ```c++
> // 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!

There are a number of changes to something like `*p == null` that I think should either be `*p == nullptr` or `*p is null`.

src/hotspot/share/gc/shared/c1/barrierSetC1.cpp line 227:

> 225:   //
> 226:   // if (offset == java_lang_ref_Reference::referent_offset()) {
> 227:   //   if (src != null) {

This "null" in a comment really should be "nullptr".

src/hotspot/share/gc/shared/generationCounters.cpp line 70:

> 68:                                        VirtualSpace* v)
> 69:   : _virtual_space(v) {
> 70:   assert(v != nullptr, "don't call this constructor if v == null");

nullptr here

src/hotspot/share/gc/shared/oopStorage.hpp line 102:

> 100: 
> 101:   // Locks _allocation_mutex.
> 102:   // precondition: ptr != null.

nullptr here

src/hotspot/share/gc/shared/oopStorage.hpp line 107:

> 105:   // Allocates and returns a new entry.  Returns null if memory allocation
> 106:   // failed.  Locks _allocation_mutex.
> 107:   // postcondition: result == null or *result == null.

nullptr here

src/hotspot/share/gc/shared/oopStorage.hpp line 123:

> 121:   // postcondition: result <= min(size, bulk_allocate_limit).
> 122:   // postcondition: ptrs[i] is an allocated entry for i in [0, result).
> 123:   // postcondition: *ptrs[i] == null for i in [0, result).

nullptr here

src/hotspot/share/gc/shared/oopStorage.hpp line 128:

> 126:   // Deallocates ptr.  No locking.
> 127:   // precondition: ptr is a valid allocated entry.
> 128:   // precondition: *ptr == null.

nullptr here

src/hotspot/share/gc/shared/oopStorage.hpp line 134:

> 132:   // release(oop*).  Best if ptrs is sorted by address.  No locking.
> 133:   // precondition: All elements of ptrs are valid allocated entries.
> 134:   // precondition: *ptrs[i] == null, for i in [0,size).

nullptr here

src/hotspot/share/gc/shared/oopStorage.hpp line 158:

> 156:   // convertible to bool.
> 157:   //
> 158:   // For weak_oops_do, if *p == null then neither is_alive nor closure will be

nullptr here

src/hotspot/share/gc/shared/oopStorageParState.hpp line 127:

> 125: //   is convertible to bool.
> 126: //
> 127: //   If *p == null then neither is_alive nor cl will be invoked for p.

nullptr here, or "*p is null".

-------------

Changes requested by kbarrett (Reviewer).

PR: https://git.openjdk.org/jdk/pull/12249


More information about the hotspot-dev mailing list